-
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
Merged
dimafeng
merged 8 commits into
testcontainers:master
from
alejandrohdezma:alias-genericcontainer-def
Nov 1, 2021
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4d27eb4
Add alias for creating a generic container definition
alejandrohdezma e609deb
Rename method to `anonymous`
alejandrohdezma 8ce1d90
Merge remote-tracking branch 'origin/master' into alias-genericcontai…
alejandrohdezma 40172b9
Rename `anonymous` to `apply`
alejandrohdezma 02561ef
Add test for `GenericContainer.Def.apply()`
alejandrohdezma 56235f3
Update README example with new method
alejandrohdezma 4e8e553
Update `GenericContainer Usage` section instead of the one previously…
alejandrohdezma 96f3404
Add missing type
alejandrohdezma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...framework/scalatest/src/test/scala/com/dimafeng/testcontainers/GenericContainerSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.dimafeng.testcontainers | ||
|
||
import org.scalatest.flatspec.AnyFlatSpec | ||
import scala.io.Source | ||
import java.net.URL | ||
import com.dimafeng.testcontainers.scalatest.TestContainerForAll | ||
import org.testcontainers.containers.wait.strategy.Wait | ||
|
||
class GenericContainerSpec extends AnyFlatSpec with TestContainerForAll { | ||
override val containerDef = GenericContainer.Def("nginx:latest", | ||
exposedPorts = Seq(80), | ||
waitStrategy = Wait.forHttp("/") | ||
) | ||
|
||
"GenericContainer" should "start nginx and expose 80 port" in withContainers { case container => | ||
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")) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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