p
munit
package munit
Linear Supertypes
Ordering
- Alphabetic
- By Inheritance
Inherited
- munit
- AnyRef
- Any
- Hide All
- Show All
Visibility
- Public
- Protected
Type Members
- abstract class HttpFromContainerSuite extends HttpSuite with TestContainersSuite
Base class for suites testing HTTP servers running in docker containers using testcontainers.
Base class for suites testing HTTP servers running in docker containers using testcontainers.
To use this class you'll need to select also one of the two testcontainers specific suites:
TestContainersForAll
orTestContainersForEach
. Also you'll need to override theval containerDef: ContainerDef
definition with your container. Lastly you'll need to ensure your container's URI is obtainable either by using the default extractor (which just useslocalhost:first-exposed-port
) or providing an specific one for your container by overriding thehttp4sMUnitContainerUriExtractor
list.import scala.concurrent.ExecutionContext.global import cats.effect.IO import cats.effect.Resource import com.dimafeng.testcontainers.ContainerDef import com.dimafeng.testcontainers.GenericContainer import com.dimafeng.testcontainers.munit.TestContainerForAll import org.http4s.Method.GET import org.http4s.client.Client import org.http4s.ember.client.EmberClientBuilder import org.http4s.client.dsl.io._ import org.http4s.syntax.all._ import org.testcontainers.containers.wait.strategy.Wait class HttpFromContainerSuiteSuite extends munit.HttpFromContainerSuite with TestContainerForAll { override def http4sMUnitClient: Resource[IO, Client[IO]] = BlazeClientBuilder[IO](global).resource override val containerDef = new ContainerDef { override type Container = GenericContainer protected def createContainer(): GenericContainer = GenericContainer( dockerImage = "briceburg/ping-pong", exposedPorts = Seq(80) ) } test(GET(uri"ping")) { response => assertEquals(response.status.code, 200) assertIO(response.as[String], "pong") } }
Example: