diff --git a/.github/codecov.yml b/.github/codecov.yml index 3fd5a2a..e31ea88 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -2,6 +2,11 @@ coverage: precision: 1 round: up range: "70...100" + status: + project: + default: + target: auto + threshold: 1% parsers: jacoco: - partials_as_hits: true \ No newline at end of file + partials_as_hits: true diff --git a/src/test/java/com/github/havlli/EventPilot/TestDatabaseContainer.java b/src/test/java/com/github/havlli/EventPilot/TestDatabaseContainer.java index 2d69475..3d2b6e2 100644 --- a/src/test/java/com/github/havlli/EventPilot/TestDatabaseContainer.java +++ b/src/test/java/com/github/havlli/EventPilot/TestDatabaseContainer.java @@ -4,6 +4,7 @@ import com.redis.testcontainers.RedisContainer; import org.flywaydb.core.Flyway; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Import; @@ -38,6 +39,7 @@ static void beforeAll() throws SQLException, IOException { postgresSQLContainer.getUsername(), postgresSQLContainer.getPassword() ).load(); + flyway.migrate(); logContainerInfo(); } @@ -120,6 +122,11 @@ protected void clearAllData() throws SQLException, IOException { executeSQLFile(CLEANUP_SQL); } + @BeforeEach + void resetDatabaseState() throws SQLException, IOException { + clearAllData(); + } + protected static void populateDummyData() throws SQLException, IOException { executeSQLFile(DATA_SQL); diff --git a/src/test/resources/cleanup.sql b/src/test/resources/cleanup.sql index 840f166..bf62edd 100644 --- a/src/test/resources/cleanup.sql +++ b/src/test/resources/cleanup.sql @@ -1,3 +1,8 @@ -DELETE FROM participant; -DELETE FROM event; -DELETE FROM guild; +TRUNCATE TABLE participant, event, guild, embed_type, user_role, users, role RESTART IDENTITY CASCADE; + +INSERT INTO embed_type (name, structure) +VALUES ('default', '{"-1":"Absence","-2":"Late","1":"Tank","-3":"Tentative","2":"Melee","3":"Ranged","4":"Healer","5":"Support"}'); + +INSERT INTO role(name) VALUES('USER'); +INSERT INTO role(name) VALUES('MODERATOR'); +INSERT INTO role(name) VALUES('ADMIN');