Skip to content

Commit

Permalink
Add a path matching test
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw committed Sep 17, 2024
1 parent 9587736 commit ae684a9
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,22 @@ class ServerBasicTests[F[_], OPTIONS, ROUTE](
basicRequest.get(uri"$baseUri/p1/abc").send(backend).map(_.code shouldBe StatusCode.BadRequest) >>
basicRequest.post(uri"$baseUri/p1/123").send(backend).map(_.code shouldBe StatusCode.Ok) >>
basicRequest.post(uri"$baseUri/p1/abc").send(backend).map(_.code shouldBe StatusCode.Ok)
},
testServer(
"two endpoints with fixed path & path capture as the middle component",
NonEmptyList.of(
route(
List[ServerEndpoint[Any, F]](
endpoint.get.in("p1" / "p2" / "p3").out(stringBody).serverLogic(_ => pureResult("1".asRight[Unit])),
endpoint.get.in("p1" / path[String]("p") / "p3").out(stringBody).serverLogic((v: String) => pureResult(s"2: $v".asRight[Unit]))
)
)
)
) { (backend, baseUri) =>
basicRequest.get(uri"$baseUri/p1/p2/p3").send(backend).map(_.body shouldBe Right("1")) >>
basicRequest.get(uri"$baseUri/p1/x/p3").send(backend).map(_.body shouldBe Right("2: x")) >>
basicRequest.get(uri"$baseUri/p1/y/p3").send(backend).map(_.body shouldBe Right("2: y")) >>
basicRequest.get(uri"$baseUri/p1/p2/p4").send(backend).map(_.code shouldBe StatusCode.NotFound)
}
)

Expand Down

0 comments on commit ae684a9

Please sign in to comment.