Skip to content

Commit

Permalink
Merge pull request #275 from greshny-forks/deprecation-warnings
Browse files Browse the repository at this point in the history
fix deprecation warning for PostgreSQLContainer
  • Loading branch information
dimafeng authored Feb 18, 2024
2 parents 512d5ee + 5b82b02 commit 97f41f2
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ class PostgreSQLContainer(
commonJdbcParams: JdbcDatabaseContainer.CommonParams = JdbcDatabaseContainer.CommonParams()
) extends SingleContainer[JavaPostgreSQLContainer[_]] with JdbcDatabaseContainer {

import PostgreSQLContainer._

override val container: JavaPostgreSQLContainer[_] = {
val c: JavaPostgreSQLContainer[_] = dockerImageNameOverride match {
case Some(imageNameOverride) =>
new JavaPostgreSQLContainer(imageNameOverride)
case None =>
new JavaPostgreSQLContainer()
}
val dockerImageName = dockerImageNameOverride.getOrElse(parsedDockerImageName)
val c: JavaPostgreSQLContainer[_] = new JavaPostgreSQLContainer(dockerImageName)

databaseName.foreach(c.withDatabaseName)
pgUsername.foreach(c.withUsername)
Expand Down Expand Up @@ -53,6 +51,9 @@ object PostgreSQLContainer {
val defaultUsername = "test"
val defaultPassword = "test"

private[testcontainers] def parsedDockerImageName: DockerImageName =
DockerImageName.parse(defaultDockerImageName)

def apply(
dockerImageNameOverride: DockerImageName = null,
databaseName: String = null,
Expand All @@ -69,7 +70,7 @@ object PostgreSQLContainer {
)

case class Def(
dockerImageName: DockerImageName = DockerImageName.parse(defaultDockerImageName),
dockerImageName: DockerImageName = parsedDockerImageName,
databaseName: String = defaultDatabaseName,
username: String = defaultUsername,
password: String = defaultPassword,
Expand Down

0 comments on commit 97f41f2

Please sign in to comment.