Skip to content

Using DockerComposeContainer in kotlin? #1010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kkocel opened this issue Dec 10, 2018 · 2 comments
Closed

Using DockerComposeContainer in kotlin? #1010

kkocel opened this issue Dec 10, 2018 · 2 comments

Comments

@kkocel
Copy link
Contributor

kkocel commented Dec 10, 2018

I'm trying to write test in kotlin + junit5 with docker compose

var environment: DockerComposeContainer<*> = DockerComposeContainer(mutableListOf(File("src/test/kotlin/resources/docker-compose.yml")))

Unfortunately I'm getting:

Type inference failed: Not enough information to infer parameter SELF in constructor DockerComposeContainer<SELF : DockerComposeContainer<SELF!>!> (composeFiles: (Mutable)List<File!>!) Please specify it explicitly.

Did anyone got same error?

@jeffzoch
Copy link

Try something like this:

object DockerContainer {
        val instance: KDockerComposeContainer by lazy { startDockerCompose()}
        class KDockerComposeContainer(file: File) : DockerComposeContainer<KDockerComposeContainer>(file)


        private fun startDockerCompose() = KDockerComposeContainer(File("integrationTests/docker-compose.start-archival.yml"))

    }

@kkocel
Copy link
Contributor Author

kkocel commented Dec 11, 2018

@jeffzoch thanks for guidance. I've created following snippet:

companion object {
    private val instance: KDockerComposeContainer by lazy { defineDockerCompose()}

    class KDockerComposeContainer(file: File) : DockerComposeContainer<KDockerComposeContainer>(file)

    private fun defineDockerCompose() = KDockerComposeContainer(File("src/test/resources/docker-compose.yml"))

    @BeforeAll
    @JvmStatic
    internal fun beforeAll() {
        instance.start()
    }

    @AfterAll
    @JvmStatic
    internal fun afterAll() {
        instance.stop()
    }
}

@kkocel kkocel closed this as completed Dec 11, 2018
willianantunes added a commit to willianantunes/kotlin-playground that referenced this issue Mar 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants