Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Saturn225 authored Oct 1, 2024
1 parent 5257f23 commit b609cd9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion zio-http/jvm/src/test/scala/zio/http/endpoint/NotFoundSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ object NotFoundSpec extends ZIOHttpSpec {
},
test("on wrong method") {
check(Gen.int, Gen.int, Gen.alphaNumericString) { (userId, postId, name) =>
val testRoutes = test404(
val testRoutes = test405(
Routes(
Endpoint(GET / "users" / int("userId"))
.out[String]
Expand Down Expand Up @@ -87,4 +87,15 @@ object NotFoundSpec extends ZIOHttpSpec {
result = response.status == Status.NotFound
} yield assertTrue(result)
}

def test405[R](service: Routes[R, Nothing])(
url: String,
method: Method,
): ZIO[R, Response, TestResult] = {
val request = Request(method = method, url = URL.decode(url).toOption.get)
for {
response <- service.runZIO(request)
result = response.status == Status.MethodNotAllowed
} yield assertTrue(result)
}
}

0 comments on commit b609cd9

Please sign in to comment.