Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
varshith257 committed Sep 18, 2024
1 parent d7f2046 commit 7dca5da
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions zio-http/jvm/src/test/scala/zio/http/HandlerAspectSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ object HandlerAspectSpec extends ZIOSpecDefault {
test("HandlerAspect should correctly combine path params and middleware context") {
val route = Method.GET / "base" / string("param") -> handler((param: String, req: Request) => {
withContext((session: Option[WebSession]) => {
val sessionId = session.map(_.id).getOrElse(-1) // Safe handling of session

ZIO.succeed(Response.text(s"Param: $param, SessionId: $sessionId"))
ZIO.succeed {
val sessionId = session.map(_.id).getOrElse(-1)
Response.text(s"Param: $param, SessionId: $sessionId")
}
})
}) @@ maybeWebSession

for {
response <- route(Request.get(URL(Path.empty / "base" / "testParam")))
bodyString <- response.body.asString
_ <- ZIO.logInfo(s"Response Body: $bodyString") // Log the final response

} yield assertTrue(bodyString == "Param: testParam, SessionId: 42")
},
test("HandlerAspect with context can eliminate environment type") {
Expand Down

0 comments on commit 7dca5da

Please sign in to comment.