diff --git a/zio-http-testkit/src/main/scala/zio/http/TestServer.scala b/zio-http-testkit/src/main/scala/zio/http/TestServer.scala index 1a439a485b..fbf50fda2f 100644 --- a/zio-http-testkit/src/main/scala/zio/http/TestServer.scala +++ b/zio-http-testkit/src/main/scala/zio/http/TestServer.scala @@ -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] diff --git a/zio-http-testkit/src/test/scala/zio/http/TestServerSpec.scala b/zio-http-testkit/src/test/scala/zio/http/TestServerSpec.scala index 20633a6251..743c7c7e28 100644 --- a/zio-http-testkit/src/test/scala/zio/http/TestServerSpec.scala +++ b/zio-http-testkit/src/test/scala/zio/http/TestServerSpec.scala @@ -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