Fix engine start/stop for integration tests
This commit is contained in:
@@ -14,6 +14,8 @@ import io.ktor.util.KtorExperimentalAPI
|
||||
import io.lettuce.core.RedisClient
|
||||
import io.lettuce.core.api.sync.RedisCommands
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.isActive
|
||||
import org.junit.jupiter.api.AfterAll
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.BeforeAll
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
@@ -32,9 +34,10 @@ abstract class BaseTest : KoinTest {
|
||||
.apply { setUri(config.rabbitmq) }
|
||||
.newConnection()
|
||||
.createChannel()
|
||||
private val engine = TestApplicationEngine(createTestEnvironment())
|
||||
}
|
||||
|
||||
private val engine = TestApplicationEngine(createTestEnvironment())
|
||||
|
||||
protected fun <R> withIntegrationApplication(
|
||||
test: TestApplicationEngine.() -> R
|
||||
): R {
|
||||
@@ -43,17 +46,24 @@ abstract class BaseTest : KoinTest {
|
||||
|
||||
@BeforeAll
|
||||
fun before() {
|
||||
if (init == false) {
|
||||
engine.start()
|
||||
engine.application.module(TEST)
|
||||
if (init == false) {
|
||||
init = true
|
||||
get<Migrations>().run {
|
||||
forceAllDown()
|
||||
run()
|
||||
}
|
||||
}
|
||||
get<Connection>()
|
||||
.sendQuery("start transaction;", listOf())
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
fun after() {
|
||||
get<Connection>()
|
||||
.sendQuery("rollback;", listOf())
|
||||
engine.stop(0, 0)
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package integration.citizen
|
||||
package integration
|
||||
|
||||
import integration.BaseTest
|
||||
import integration.asserts.`And have property`
|
||||
@@ -1,4 +1,4 @@
|
||||
package integration.auth
|
||||
package integration
|
||||
|
||||
import integration.BaseTest
|
||||
import integration.asserts.`And the response should not be null`
|
||||
@@ -1,6 +1,5 @@
|
||||
package integration.auth
|
||||
package integration
|
||||
|
||||
import integration.BaseTest
|
||||
import integration.asserts.`Then the response should be`
|
||||
import integration.asserts.`when`.`When I send a POST request`
|
||||
import io.ktor.http.HttpStatusCode
|
||||
Reference in New Issue
Block a user