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 { override fun initialize(applicationContext: ConfigurableApplicationContext) { TestPropertyValues.of(TestContainerPostgres.props()).applyTo(applicationContext.environment) } override fun beforeAll(context: ExtensionContext) { if (!TestContainerPostgres.postgres.isRunning) { TestContainerPostgres.postgres.start() } } }