zio.http.TestClient
See theTestClient companion object
final case class TestClient(behavior: Ref[PartialFunction[Request, ZIO[Any, Response, Response]]], serverSocketBehavior: Ref[WebSocketApp[Any]]) extends Driver[Any, Throwable]
Enables tests that use a client without needing a live Server
Value parameters
- behavior
-
Contains the user-specified behavior that takes the place of the usual Server
Attributes
- Companion
- object
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
def addHandler[R](handler: PartialFunction[Request, ZIO[R, Response, Response]]): ZIO[R, Nothing, Unit]
Adds a flexible handler for requests that are submitted by test cases
Adds a flexible handler for requests that are submitted by test cases
Type parameters
- R
-
Environment of the new handler's effect.
Value parameters
- handler
-
New behavior to be added to the TestClient
Attributes
- Example
-
TestClient.addHandler{case request if request.method == Method.GET => ZIO.succeed(Response.ok)}
Adds an exact 1-1 behavior
Adds an exact 1-1 behavior
Value parameters
- expectedRequest
-
The request that will trigger the response
- response
-
The response to be returned when a user submits the response
Attributes
- Example
-
TestClient.addRequestResponse(Request.get(URL.root), Response.ok)
Attributes
- Definition Classes
In this article