All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dimafeng.testcontainers.CockroachContainer.scala Maven / Gradle / Ivy

There is a newer version: 0.41.4
Show newest version
package com.dimafeng.testcontainers

import org.testcontainers.containers.{CockroachContainer => JavaCockroachContainer}
import org.testcontainers.utility.DockerImageName

case class CockroachContainer(
  dockerImageName: DockerImageName = DockerImageName.parse(CockroachContainer.defaultDockerImageName),
  urlParams: Map[String, String] = Map.empty,
  commonJdbcParams: JdbcDatabaseContainer.CommonParams = JdbcDatabaseContainer.CommonParams()
) extends SingleContainer[JavaCockroachContainer] with JdbcDatabaseContainer {

  override val container: JavaCockroachContainer = {
    val c = new JavaCockroachContainer(dockerImageName)

    urlParams.foreach { case (key, value) =>
      c.withUrlParam(key, value)
    }

    commonJdbcParams.applyTo(c)

    c
  }

  def testQueryString: String = container.getTestQueryString
}

object CockroachContainer {

  val defaultDockerImageName = s"${JavaCockroachContainer.IMAGE}:${JavaCockroachContainer.IMAGE_TAG}"

  case class Def(
    dockerImageName: DockerImageName = DockerImageName.parse(CockroachContainer.defaultDockerImageName),
    urlParams: Map[String, String] = Map.empty,
    commonJdbcParams: JdbcDatabaseContainer.CommonParams = JdbcDatabaseContainer.CommonParams()
  ) extends ContainerDef {

    override type Container = CockroachContainer

    override def createContainer(): CockroachContainer = {
      new CockroachContainer(
        dockerImageName,
        urlParams,
        commonJdbcParams
      )
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy