Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
varshith257 committed Sep 10, 2024
1 parent 2a79912 commit a7302b1
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions zio-http/jvm/src/test/scala/zio/http/RoutesSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ object RoutesSpec extends ZIOHttpSpec {
}
}

val endpoint = Endpoint(RoutePattern.GET / "test")
.outCodec[String](StatusCodec.Ok ++ HttpCodec.content[String])
.auth(AuthType.Basic)

def spec = suite("RoutesSpec")(
test("empty not found") {
val app = Routes.empty
Expand Down Expand Up @@ -121,14 +117,21 @@ object RoutesSpec extends ZIOHttpSpec {
)
}
},
test("HandlerAspect works with Routes with multiple dependencies") {
val routeWithMultipleDependencies: Route[Int & Long & String, Nothing] =
endpoint.implement((_: Unit) => ZIO.service[Int].zip(ZIO.service[Long]).map(_ => "multiple-dependencies"))
test("HandlerAspect works with multiple dependencies in Scala 2") {
val routeWithMultipleDeps = Method.GET / "multiple-deps" -> handler { _: Request =>
for {
intDep <- ZIO.service[Int]
longDep <- ZIO.service[Long]
} yield Response.text(s"Int: $intDep, Long: $longDep")
}

val routesWithAspect: Routes[(Int, Long), Nothing] =
Routes(routeWithMultipleDependencies).@@[(Int, Long)](authContext)
val routesWithAspect = Routes(routeWithMultipleDeps).@@[Int with Long](authContext)

assertTrue(routesWithAspect != null)
for {
result <- routesWithAspect
.runZIO(Request.get("/multiple-deps"))
.provideLayer(ZLayer.succeed(42) ++ ZLayer.succeed(100L))
} yield assertTrue(result.status == Status.Ok && result.body.asString == "Int: 42, Long: 100")
},
)
}

0 comments on commit a7302b1

Please sign in to comment.