generated from aura-ascend/template-library
22 lines
897 B
Kotlin
22 lines
897 B
Kotlin
package ltd.lulz.test.container.extension
|
|
|
|
import ltd.lulz.test.container.postgres.TestContainerPostgres
|
|
import org.junit.jupiter.api.extension.BeforeAllCallback
|
|
import org.junit.jupiter.api.extension.ExtensionContext
|
|
import org.springframework.boot.test.util.TestPropertyValues
|
|
import org.springframework.context.ApplicationContextInitializer
|
|
import org.springframework.context.ConfigurableApplicationContext
|
|
|
|
class PostgresTestExtension : BeforeAllCallback, ApplicationContextInitializer<ConfigurableApplicationContext> {
|
|
|
|
override fun initialize(applicationContext: ConfigurableApplicationContext) {
|
|
TestPropertyValues.of(TestContainerPostgres.props()).applyTo(applicationContext.environment)
|
|
}
|
|
|
|
override fun beforeAll(context: ExtensionContext) {
|
|
if (!TestContainerPostgres.postgres.isRunning) {
|
|
TestContainerPostgres.postgres.start()
|
|
}
|
|
}
|
|
}
|