TestClient

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
trait Serializable
trait Product
trait Equals
trait Driver[Any, Throwable]
class Object
trait Matchable
class Any
Show all

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)}
def addRequestResponse(expectedRequest: Request, response: Response): ZIO[Any, Nothing, Unit]

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)
def installSocketApp[Env1](app: WebSocketApp[Any]): ZIO[Env1, Nothing, Unit]
def method: Method
override def request(version: Version, method: Method, url: URL, headers: Headers, body: Body, sslConfig: Option[ClientSSLConfig], proxy: Option[Proxy])(implicit trace: Trace): ZIO[Any, Throwable, Response]

Attributes

Definition Classes
def socket[Env1](version: Version, url: URL, headers: Headers, app: WebSocketApp[Env1])(implicit trace: Trace): ZIO[Env1 & Scope, Throwable, Response]
def url: URL

Inherited methods

final def apply(request: Request)(implicit trace: Trace): ZIO[Env & Scope, Err, Response]

Attributes

Inherited from:
Driver
final def disableStreaming(implicit ev: Throwable <:< Throwable): Driver[Env, Throwable]

Attributes

Inherited from:
Driver
final def mapError[Err2](f: Throwable => Err2): Driver[Env, Err2]

Attributes

Inherited from:
Driver

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product

Attributes

Inherited from:
Driver
final def request(req: Request)(implicit trace: Trace): ZIO[Env & Scope, Err, Response]

Attributes

Inherited from:
Driver
final def retry[Env1, Err1 >: Throwable](policy: Schedule[Env1, Err1, Any]): Driver[Env1, Err1]

Attributes

Inherited from:
Driver
def widenError[E1](implicit ev: Throwable <:< E1): Driver[Env, E1]

Attributes

Inherited from:
Driver