Skip to content

Commit

Permalink
test: add a test case for retrying code gen after first attempt failed
Browse files Browse the repository at this point in the history
due to Docker being unavailable
  • Loading branch information
monosoul committed Oct 20, 2023
1 parent 9ca87fa commit 6078aaf
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package dev.monosoul.jooq.artifact

import org.junit.jupiter.api.Test
import org.testcontainers.utility.MountableFile.forClasspathResource
import strikt.api.expect
import strikt.assertions.contains
import strikt.assertions.isSuccess

class WorksAfterFailingToFindDockerArtifactTest {

@Test
fun `should be possible to generate jooq classes even after it failed on first attempt`() {
// given
val gradleContainer = GradleContainer(dockerSocketPath = "/var/run/docker-alt.sock").apply {
withEnv("TESTCONTAINERS_RYUK_DISABLED", "true")
withCopyToContainer(forClasspathResource("/testproject"), projectPath)
withCopyToContainer(forClasspathResource("/gradle_run.sh"), "/gradle_run.sh")
withCommand("/gradle_run.sh")
}

// when & then
expect {
catching {
gradleContainer.start()
gradleContainer.stop()
}.isSuccess()

that(gradleContainer.output).contains("BUILD SUCCESSFUL in ")
}
}
}
8 changes: 8 additions & 0 deletions artifact-tests/src/test/resources/gradle_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

gradle classes --info --stacktrace

export DOCKER_HOST=unix:///var/run/docker-alt.sock
export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker-alt.sock

gradle classes --info --stacktrace

0 comments on commit 6078aaf

Please sign in to comment.