From def3c11981f4a1d96a158344f51afefc3d8182eb Mon Sep 17 00:00:00 2001 From: Joakim Taule Kartveit Date: Fri, 10 Nov 2023 09:06:42 +0100 Subject: [PATCH] Copy folders --- .../kotlin/no/nav/pdfgen/DockerImageTest.kt | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/test/kotlin/no/nav/pdfgen/DockerImageTest.kt b/src/test/kotlin/no/nav/pdfgen/DockerImageTest.kt index 598534a..9be1cd1 100644 --- a/src/test/kotlin/no/nav/pdfgen/DockerImageTest.kt +++ b/src/test/kotlin/no/nav/pdfgen/DockerImageTest.kt @@ -21,24 +21,34 @@ import org.testcontainers.utility.MountableFile import kotlin.io.path.Path internal class DockerImageTest { - private val network = Network.newNetwork() - // - private var pdfgenContainer = - GenericContainer( - ImageFromDockerfile().withDockerfile(Path("./Dockerfile")), - ) - .withCopyToContainer(MountableFile.forHostPath(Path("./build/libs/app-2.0.0.jar")), "/app/app-2.0.0.jar") - .withCopyToContainer(MountableFile.forHostPath(Path("./fonts/")), "/app/fonts/") - .withCopyToContainer(MountableFile.forHostPath(Path("./templates/")), "/app/templates/") - .withCopyToContainer(MountableFile.forHostPath(Path("./resources/")), "/app/resources/") - .withNetwork(network) - .withExposedPorts(8080) - .waitingFor(Wait.forHttp("/internal/is_ready")) - .apply { start() } @Test internal fun `Test Dockerfile`() { + val network = Network.newNetwork() + + val pdfgenContainer = + GenericContainer( + ImageFromDockerfile() + .withDockerfile(Path("./Dockerfile")), + ) + .withCopyToContainer( + MountableFile.forHostPath(Path("./build/libs/app-2.0.0.jar")), + "/app/app-2.0.0.jar", + ) + .withCopyToContainer(MountableFile.forHostPath(Path("./fonts/")), "/app/fonts") + .withCopyToContainer( + MountableFile.forHostPath(Path("./templates/")), + "/app/templates", + ) + .withCopyToContainer( + MountableFile.forHostPath(Path("./resources/")), + "/app/resources", + ) + .withNetwork(network) + .withExposedPorts(8080) + .waitingFor(Wait.forHttp("/internal/is_ready")) + .apply { start() } runBlocking { val pdfgenContainerUrlIsReady = pdfgenContainer.buildUrl("internal/is_ready") @@ -61,6 +71,7 @@ internal class DockerImageTest { Assertions.assertEquals(HttpStatusCode.OK, response.status) } } + private fun GenericContainer<*>.buildUrl(url: String) = "http://${this.host}:${this.getMappedPort(8080)}/$url" }