mirror of
https://github.com/google/nomulus.git
synced 2025-07-09 20:53:26 +02:00
Add by-repo-id method to RegistryLockDao (#344)
* Add by-repo-id method to RegistryLockDao When we create new registry lock objects on user request, we will want to make sure that there are no pending lock/unlock actions on this domain. In order to do that, we will need to know what lock actions there have been for this domain. * Inline the query into a single statement * whoops * comments
This commit is contained in:
parent
b005e3aeb0
commit
a392100852
2 changed files with 42 additions and 0 deletions
|
@ -120,6 +120,26 @@ public final class RegistryLockDaoTest {
|
|||
assertThat(RegistryLockDao.getByRegistrarId("nonexistent")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoad_byRepoId() {
|
||||
RegistryLock completedLock =
|
||||
createLock().asBuilder().setCompletionTimestamp(jpaTmRule.getTxnClock().nowUtc()).build();
|
||||
RegistryLockDao.save(completedLock);
|
||||
|
||||
jpaTmRule.getTxnClock().advanceOneMilli();
|
||||
RegistryLock inProgressLock = createLock();
|
||||
RegistryLockDao.save(inProgressLock);
|
||||
|
||||
Optional<RegistryLock> mostRecent = RegistryLockDao.getMostRecentByRepoId("repoId");
|
||||
assertThat(mostRecent.isPresent()).isTrue();
|
||||
assertThat(mostRecent.get().isVerified()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoad_byRepoId_empty() {
|
||||
assertThat(RegistryLockDao.getMostRecentByRepoId("nonexistent").isPresent()).isFalse();
|
||||
}
|
||||
|
||||
private RegistryLock createLock() {
|
||||
return new RegistryLock.Builder()
|
||||
.setRepoId("repoId")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue