What is the point of `ContainerDef`?
solarmosaic-kflorence opened this issue · comments
How am I supposed to use ContainerDef
? How is it better than just constructing a container itself? Looking at the code, and through use-cases at our company, it seems that at best using ContainerDef
creates extra boilerplate we have to maintain in two places (the container settings), and at worst we can't use it at all because we need access to Container.configure
in order to configure the underlying container when explicit settings for it aren't defined (quite often). The only real benefit I see currently is that the start()
method in the ContainerDef
returns the container instead of Unit
.
Actually I think ContainerDef
might make more sense for consumers of testcontainers-scala
to use, rather than being part of the testcontainers-scala
implementation. For example, let's say I wanted to use the PostgreSQLContainer
. I could make my own ContainerDef
for that container that encapsulates whatever settings that make sense for my use-case, and then internally we could use that instead of using the container directly. So actually, that seems to be the main benefit.
I think it's a little confusing that the default implementation has ContainerDef
already defined for the provided testcontainer modules, but I guess it doesn't hurt because you can just ignore them as a consumer of the library. Probably this DSL just needs to be documented better.
You can find a detailed discussion in the PR: #78
Yeah I saw that discussion some months ago. It's just that nothing in the TestContainersForAll
API actually forces you to use ContainerDef
-- you can just use the Container
itself if you wanted to. So I was trying to understand the benefit.