forked from Archives/Athou_commafeed
faster integration tests execution by truncating tables instead of dropping and recreating tables
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
package com.commafeed;
|
package com.commafeed;
|
||||||
|
|
||||||
import jakarta.enterprise.inject.spi.CDI;
|
import jakarta.enterprise.inject.spi.CDI;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
|
||||||
|
import org.hibernate.Session;
|
||||||
import org.kohsuke.MetaInfServices;
|
import org.kohsuke.MetaInfServices;
|
||||||
|
|
||||||
import com.commafeed.backend.service.db.DatabaseStartupService;
|
import com.commafeed.backend.service.db.DatabaseStartupService;
|
||||||
|
|
||||||
import io.quarkus.liquibase.runtime.LiquibaseSchemaProvider;
|
|
||||||
import io.quarkus.test.junit.callback.QuarkusTestBeforeEachCallback;
|
import io.quarkus.test.junit.callback.QuarkusTestBeforeEachCallback;
|
||||||
import io.quarkus.test.junit.callback.QuarkusTestMethodContext;
|
import io.quarkus.test.junit.callback.QuarkusTestMethodContext;
|
||||||
|
|
||||||
@@ -18,7 +19,14 @@ public class DatabaseReset implements QuarkusTestBeforeEachCallback {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeEach(QuarkusTestMethodContext context) {
|
public void beforeEach(QuarkusTestMethodContext context) {
|
||||||
new LiquibaseSchemaProvider().resetAllDatabases();
|
CDI.current()
|
||||||
|
.select(EntityManager.class)
|
||||||
|
.get()
|
||||||
|
.unwrap(Session.class)
|
||||||
|
.getSessionFactory()
|
||||||
|
.getSchemaManager()
|
||||||
|
.truncateMappedObjects();
|
||||||
|
|
||||||
CDI.current().select(DatabaseStartupService.class).get().populateInitialData();
|
CDI.current().select(DatabaseStartupService.class).get().populateInitialData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user