Skip to content

Commit

Permalink
Update GenericContainer Usage section instead of the one previously…
Browse files Browse the repository at this point in the history
… updated
  • Loading branch information
alejandrohdezma committed Oct 24, 2021
1 parent 56235f3 commit 4e8e553
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ The most flexible but less convenient container type is `GenericContainer`. This
with custom configuration.

```scala
class GenericContainerSpec extends AnyFlatSpec with TestContainerForAll {
override val containerDef = GenericContainer.Def("nginx:latest",
class GenericContainerSpec extends AnyFlatSpec with ForAllTestContainer {
override val container: GenericContainer = GenericContainer("nginx:latest",
exposedPorts = Seq(80),
waitStrategy = Wait.forHttp("/")
)

"GenericContainer" should "start nginx and expose 80 port" in withContainers { case container =>
"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"))
Expand Down Expand Up @@ -455,6 +455,15 @@ object NginxContainer {
}
```

However, if you don't want to create a custom container, you can use `GenericContainer` directly while overriding `containerDef`:

```scala
override val containerDef = GenericContainer.Def("nginx:latest",
exposedPorts = Seq(80),
waitStrategy = Wait.forHttp("/")
)
```

### Migration from the classic API

1. If you have custom containers created with the `GenericContainer`, add `ContainerDef` in the companion like this:
Expand Down

0 comments on commit 4e8e553

Please sign in to comment.