This repository was archived by the owner on Feb 16, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
main/kotlin/io/kotest/extensions/testcontainers
test/kotlin/io/kotest/extensions/testcontainers Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -73,16 +73,16 @@ class ContainerExtension<T : GenericContainer<*>>(
7373
7474 /* *
7575 * Mounts the container, starting it if necessary. The [configure] block will be invoked
76- * every time the container is mounted, and after the container has started.
76+ * every time the [ContainerExtension] is mounted, before the container is started.
7777 */
7878 override fun mount (configure : T .() -> Unit ): T = container.apply {
79+ configure()
80+
7981 if (! isRunning) {
8082 beforeStart()
8183 start()
8284 afterStart()
8385 }
84-
85- configure()
8686 }
8787
8888 override suspend fun beforeTest (testCase : TestCase ) {
Original file line number Diff line number Diff line change @@ -4,12 +4,15 @@ import com.redis.testcontainers.RedisContainer
44import io.kotest.core.extensions.install
55import io.kotest.core.spec.style.FunSpec
66import io.kotest.matchers.shouldBe
7+ import org.testcontainers.containers.GenericContainer
78import redis.clients.jedis.JedisPool
89
910class ContainerExtensionSpecLifecycleTest : FunSpec () {
1011 init {
1112
12- val container = install(ContainerExtension (RedisContainer (" 7.2.5-alpine" ), ContainerLifecycleMode .Spec )) {
13+ // Using GenericContainer (which includes no out-of-the-box port mappings
14+ // to ensure the configure hook exposes ports correctly
15+ val container = install(ContainerExtension (GenericContainer (" redis:7.2.5-alpine" ), ContainerLifecycleMode .Spec )) {
1316 startupAttempts = 2
1417 withExposedPorts(6379 )
1518 }
You can’t perform that action at this time.
0 commit comments