(test) Fix broken test

This commit is contained in:
Viktor Lofgren 2024-01-20 13:39:40 +01:00
parent 91c7960800
commit c5760cd535

View File

@ -33,6 +33,14 @@ class DomainRankingSetsServiceTest {
dataSource = new HikariDataSource(config); dataSource = new HikariDataSource(config);
TestMigrationLoader.flywayMigration(dataSource); TestMigrationLoader.flywayMigration(dataSource);
// The migration SQL will insert a few default values, we want to remove them
wipeDomainRankingSets(dataSource);
}
@AfterEach
public void tearDown() {
wipeDomainRankingSets(dataSource);
} }
@AfterAll @AfterAll
@ -45,10 +53,6 @@ class DomainRankingSetsServiceTest {
public void testScenarios() throws Exception { public void testScenarios() throws Exception {
var service = new DomainRankingSetsService(dataSource); var service = new DomainRankingSetsService(dataSource);
// Clean up default values
service.get("BLOGS").ifPresent(service::delete);
service.get("NONE").ifPresent(service::delete);
var newValue = new DomainRankingSetsService.DomainRankingSet( var newValue = new DomainRankingSetsService.DomainRankingSet(
"test", "test",
"Test domain set", "Test domain set",
@ -81,4 +85,9 @@ class DomainRankingSetsServiceTest {
allValues = service.getAll(); allValues = service.getAll();
assertEquals(0, allValues.size()); assertEquals(0, allValues.size());
} }
private static void wipeDomainRankingSets(HikariDataSource dataSource) {
var service = new DomainRankingSetsService(dataSource);
service.getAll().forEach(service::delete);
}
} }