From c5760cd5350e746b2ae77659e220de774bca21ce Mon Sep 17 00:00:00 2001 From: Viktor Lofgren Date: Sat, 20 Jan 2024 13:39:40 +0100 Subject: [PATCH] (test) Fix broken test --- .../db/DomainRankingSetsServiceTest.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/code/common/db/src/test/java/nu/marginalia/db/DomainRankingSetsServiceTest.java b/code/common/db/src/test/java/nu/marginalia/db/DomainRankingSetsServiceTest.java index 999f1a7e..797e2b55 100644 --- a/code/common/db/src/test/java/nu/marginalia/db/DomainRankingSetsServiceTest.java +++ b/code/common/db/src/test/java/nu/marginalia/db/DomainRankingSetsServiceTest.java @@ -33,6 +33,14 @@ class DomainRankingSetsServiceTest { dataSource = new HikariDataSource(config); 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 @@ -45,10 +53,6 @@ class DomainRankingSetsServiceTest { public void testScenarios() throws Exception { 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( "test", "Test domain set", @@ -81,4 +85,9 @@ class DomainRankingSetsServiceTest { allValues = service.getAll(); assertEquals(0, allValues.size()); } + + private static void wipeDomainRankingSets(HikariDataSource dataSource) { + var service = new DomainRankingSetsService(dataSource); + service.getAll().forEach(service::delete); + } } \ No newline at end of file