Enables tests that make calls against "localhost" with user-specified Behavior/Responses.
- Value parameters:
- bindPort
Port for HTTP interactions
- driver
The web driver that accepts our Server behavior
- Companion:
- object
Value members
Concrete methods
Add new behavior to Server
Add new behavior to Server
- Value parameters:
- pf
New behavior
- Example:
for { state <- Ref.make(0) testRequest <- requestToCorrectPort _ <- TestServer.addHandler{ case (_: Request) => for { curState <- state.getAndUpdate(_ + 1) } yield { if (curState > 0) Response(Status.InternalServerError) else Response(Status.Ok) } }
Define 1-1 mappings between incoming Requests and outgoing Responses
Define 1-1 mappings between incoming Requests and outgoing Responses
- Value parameters:
- expectedRequest
Request that will trigger the provided Response
- response
Response that the Server will send
- Example:
TestServer.addRequestResponse(Request.get(url = URL.root.setPort(port = ???)), Response(Status.Ok))