-
Notifications
You must be signed in to change notification settings - Fork 126
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
Add alias for creating a generic container definition #194
Add alias for creating a generic container definition #194
Conversation
Hey @LMnet I'm a bit rusty on the original idea of Def. Do you remember why it wasn't added initially? |
I tried to compile your example but it's not compiling. Could you fix it? After that, we will be able to discuss your idea in more detail. |
Hey @LMnet, thanks for the swift response? What exactly is not compiling? I just run |
I'm talking about your example in the merge request description: class GenericContainerSpec extends AnyFlatSpec with TestContainersForAll {
override val containerDef = GenericContainer.Def("nginx:latest",
exposedPorts = Seq(80),
waitStrategy = Wait.forHttp("/")
)
"GenericContainer" should "start nginx and expose 80 port" in {
assert(Source.fromInputStream(
new URL(s"http://${container.containerIpAddress}:${container.mappedPort(80)}/").openConnection().getInputStream
).mkString.contains("If you see this page, the nginx web server is successfully installed"))
}
} |
Signed-off-by: Alejandro Hernández <[email protected]>
Thanks @LMnet, I have updated the example and the changes. The example was using the wrong trait and missing the |
Thanks, @alejandrohdezma Now it looks fine. But I'm a bit concerned about the impact of this |
Signed-off-by: Alejandro Hernández <[email protected]>
@LMnet done! |
@alejandrohdezma would you mind updating your example snippet. It seems I'm not following the idea with |
Done! |
Hey @LMnet quick question - why |
All my concerns I described above. The default use case for Overall, If we will use |
Got it! It makes sense. @LMnet @alejandrohdezma would it make sense to create a new class instead e.g. |
Of course! I'll send a new commit tomorrow morning :( |
Thanks! @LMnet does it sound good to you? |
@dimafeng I'm not sure. Discoverability of |
If we go with that I would remove the |
Seems we're comparing several non-ideal solutions:
4th option: |
Sorry @dimafeng I didn't see your reply :( What I like about the |
After thinking a bit, I'm leaning toward your options with @LMnet any final thoughts? |
I prefer option 1. But option 3 is acceptable. |
@alejandrohdezma can we proceed with the option 3? Would you mind also changing README and adding a simple test? |
Of course, I'll do it as soon as possible :) |
Done! :) |
@alejandrohdezma thank you! Seems some tests failed |
README.md
Outdated
@@ -181,13 +181,13 @@ The most flexible but less convenient container type is `GenericContainer`. This | |||
with custom configuration. | |||
|
|||
```scala | |||
class GenericContainerSpec extends AnyFlatSpec with ForAllTestContainer { | |||
override val container: GenericContainer = GenericContainer("nginx:latest", | |||
class GenericContainerSpec extends AnyFlatSpec with TestContainerForAll { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we update this section instead - https://github.com/testcontainers/testcontainers-scala#genericcontainer-usage
I'd like to keep it consistent until we finally migrate to one way of doing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done here: 4e8e553
@alejandrohdezma thanks! The test is failing with scala 3
|
@dimafeng should be fixed now |
Just adds an alias for creating a
ContainerDef
for aGenericContainer
that doesn't involve creating a new object/class.Example: