Skip to content

Commit

Permalink
zio-http-2559 Update the test kit so that it supports the current dev…
Browse files Browse the repository at this point in the history
…elopment style as supported ...

Add documentation

Took 8 minutes
  • Loading branch information
gmixa committed Dec 22, 2023
1 parent 365bbc9 commit 6a4444b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions zio-http-testkit/src/main/scala/zio/http/TestServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,28 @@ final case class TestServer(driver: Driver, bindPort: Int) extends Server {
_ <- driver.addApp(app, r)
} yield ()

/**
* @param routes new routes
* @tparam Env environment
* @return
*
* @example
* {{{
* for{
client <- ZIO.service[Client]
testRequest <- requestToCorrectPort
_ <- TestServer.addRoutes(
Routes(
Method.GET / PathCodec.empty -> handler {
Response.ok
}
)
)
response <- client(testRequest)
} yield assertTrue(status(response)==Status.Ok)
* }}}
*/
def addRoutes[Env](routes : Routes[Env,Response]): ZIO[Env, Nothing, Unit] =
for{
env <- ZIO.environment[Env]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ object TestServerSpec extends ZIOHttpSpec {
Scope.default,
),
suite("Test Routes")(
test("Get A Respones Ok"){
test("Get a Response for Ok"){
for{
client <- ZIO.service[Client]
testRequest <- requestToCorrectPort
Expand Down

0 comments on commit 6a4444b

Please sign in to comment.