Reset the claims list cache in any test that saves to it (#1754)

This commit is contained in:
gbrodman 2022-08-22 15:58:45 -04:00 committed by GitHub
parent 280b56bd51
commit ad50d6b0c7
2 changed files with 12 additions and 0 deletions

View file

@ -22,14 +22,20 @@ import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import google.registry.model.tmch.ClaimsList; import google.registry.model.tmch.ClaimsList;
import google.registry.model.tmch.ClaimsListDao; import google.registry.model.tmch.ClaimsListDao;
import google.registry.testing.TestCacheExtension;
import java.io.File; import java.io.File;
import java.nio.file.Files; import java.nio.file.Files;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/** Unit tests for {@link GetClaimsListCommand}. */ /** Unit tests for {@link GetClaimsListCommand}. */
class GetClaimsListCommandTest extends CommandTestCase<GetClaimsListCommand> { class GetClaimsListCommandTest extends CommandTestCase<GetClaimsListCommand> {
@RegisterExtension
public final TestCacheExtension testCacheExtension =
new TestCacheExtension.Builder().withClaimsListCache(java.time.Duration.ofHours(6)).build();
@Test @Test
void testSuccess_getWorks() throws Exception { void testSuccess_getWorks() throws Exception {
ClaimsListDao.save(ClaimsList.create(DateTime.now(UTC), ImmutableMap.of("a", "1", "b", "2"))); ClaimsListDao.save(ClaimsList.create(DateTime.now(UTC), ImmutableMap.of("a", "1", "b", "2")));

View file

@ -20,13 +20,19 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import google.registry.model.tmch.ClaimsList; import google.registry.model.tmch.ClaimsList;
import google.registry.model.tmch.ClaimsListDao; import google.registry.model.tmch.ClaimsListDao;
import google.registry.testing.TestCacheExtension;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/** Unit tests for {@link UploadClaimsListCommand}. */ /** Unit tests for {@link UploadClaimsListCommand}. */
class UploadClaimsListCommandTest extends CommandTestCase<UploadClaimsListCommand> { class UploadClaimsListCommandTest extends CommandTestCase<UploadClaimsListCommand> {
@RegisterExtension
public final TestCacheExtension testCacheExtension =
new TestCacheExtension.Builder().withClaimsListCache(java.time.Duration.ofHours(6)).build();
@Test @Test
void testSuccess() throws Exception { void testSuccess() throws Exception {
String filename = writeToTmpFile( String filename = writeToTmpFile(