I am trying to use library testcontainers which has following contract
PostgreSQLContainer<SELF extends PostgreSQLContainer<SELF>>
[0]. I am not sure how to create a new instance for that because when creating with
val postgresql = new PostgreSQLContainer[_]("postgres:9.6.2")
the compiler complains
class type required but org.testcontainers.containers.PostgreSQLContainer[_] found
And if creating with
val postgresql = new PostgreSQLContainer[PostgreSQLContainer[_]]("postgres:9.6.2").withUsername("test").withPassword("test")
the compiler throws error
type arguments [org.testcontainers.containers.PostgreSQLContainer[_]] do not conform to class PostgreSQLContainer's type parameter bounds [SELF <: org.testcontainers.containers.PostgreSQLContainer[SELF]]
And if creating with statement
val postgresql = new PostgreSQLContainer("postgres:9.6.2").withUsername("test").withPassword("test")
error value withPassword is not a member of Nothing
is thrown.
I can new instance with just val postgresql = new PostgreSQLContainer("postgres:9.6.2")
, but that’s not what I want because I want to change username and password.
What is the right way to instantiate this class in scala way?
Thanks