Created
July 17, 2020 18:26
-
-
Save iainporter/04dcf2bb8564df22f9308a5e73151c90 to your computer and use it in GitHub Desktop.
Base class for component tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class TestEnvironment { | |
@Before | |
fun setup() { | |
val port = env.getServicePort("sms-service_1", 8080) | |
RestAssured.baseURI = "http://localhost:$port" | |
} | |
companion object { | |
val env: KDockerComposeContainer by lazy {initDockerCompose()} | |
class KDockerComposeContainer(path: File) : DockerComposeContainer<KDockerComposeContainer>(path) | |
private fun initDockerCompose() = KDockerComposeContainer(File("src/test/resources/docker-compose.yml")) | |
.withExposedService("sms-service_1", 8080) | |
.withExposedService("postgres-db_1", 5432) | |
.waitingFor("sms-service", Wait.forHttp("/health")) | |
init { | |
env.start() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment