Skip to content

Commit

Permalink
Ensure URI can be obtained from a wider variety of containers (#25)
Browse files Browse the repository at this point in the history
* Use first available port instead of hardcoding `80`

* Use `SingleContainer` instead of `GenericContainer` since it is higher

* Add needed suppression
  • Loading branch information
alejandrohdezma authored Feb 9, 2021
1 parent 604336d commit 2356061
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@

package munit

import com.dimafeng.testcontainers.GenericContainer
import com.dimafeng.testcontainers.SingleContainer
import org.http4s.Uri
import org.testcontainers.containers.GenericContainer

@SuppressWarnings(Array("scalafix:Disable.head"))
trait LowPrecedenceContainer2Uri {

implicit def GenericContainer2Uri[A <: GenericContainer]: A => Uri = container =>
Uri.unsafeFromString(s"http://localhost:${container.mappedPort(80)}")
implicit def GenericContainer2Uri[A <: SingleContainer[GenericContainer[_]]]: A => Uri = container =>
Uri.unsafeFromString(s"http://localhost:${container.mappedPort(container.exposedPorts.head)}")

}

0 comments on commit 2356061

Please sign in to comment.