TestClient

zio.http.TestClient
See theTestClient companion object
final case class TestClient(behavior: Ref[HttpApp[Any, Throwable]], serverSocketBehavior: Ref[SocketApp[Any]]) extends Client

Enables tests that use a client without needing a live Server

Attributes

behavior

Contains the user-specified behavior that takes the place of the usual Server

Companion:
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Concrete methods

def addHandler[R](handler: PartialFunction[Request, ZIO[R, Throwable, 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

Attributes

R

Environment of the new handler's effect.

handler

New behavior to be added to the TestClient

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

Attributes

expectedRequest

The request that will trigger the response

response

The response to be returned when a user submits the response

Example:
  TestClient.addRequestResponse(Request.get(URL.root), Response.ok)

Returns the headers

Returns the headers

Attributes

def installSocketApp[Env1](app: Http[Any, Throwable, WebSocketChannelEvent, Unit]): ZIO[Env1, Nothing, Unit]
override def request(version: Version, method: Method, url: URL, headers: Headers, body: Body, sslConfig: Option[ClientSSLConfig])(implicit trace: Trace): ZIO[Any, Throwable, Response]

Attributes

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

Inherited methods

final def @@[LowerEnv <: UpperEnv, UpperEnv, LowerIn <: UpperIn, UpperIn <: Body, LowerErr >: Throwable, UpperErr >: LowerErr, LowerOut >: Response, UpperOut >: LowerOut](aspect: ZClientAspect[LowerEnv, UpperEnv, LowerIn, UpperIn, LowerErr, UpperErr, LowerOut, UpperOut]): ZClient[UpperEnv, UpperIn, LowerErr, LowerOut]

Applies the specified client aspect, which can modify the execution of this client.

Applies the specified client aspect, which can modify the execution of this client.

Attributes

Inherited from:
ZClient
final def addHeader(name: CharSequence, value: CharSequence): A

Attributes

Inherited from:
HeaderModifier
final def addHeader(header: Header): A

Attributes

Inherited from:
HeaderModifier
final def addHeaders(headers: Headers): A

Attributes

Inherited from:
HeaderModifier
final def contramap[In2](f: In2 => Body): ZClient[Env, In2, Err, Out]

Attributes

Inherited from:
ZClient
final def contramapZIO[Env1, Err1 >: Throwable, In2](f: In2 => ZIO[Env1, Err1, Body]): ZClient[Env1, In2, Err1, Out]

Attributes

Inherited from:
ZClient
final def delete(pathSuffix: String)(implicit trace: Trace, ev: Body <:< Body): ZIO[Env, Err, Out]

Attributes

Inherited from:
ZClient
final def delete(pathSuffix: String, body: Body)(implicit trace: Trace): ZIO[Env, Err, Out]

Attributes

Inherited from:
ZClient
final def dieOn(f: Throwable => Boolean)(implicit ev1: IsSubtypeOfError[Throwable, Throwable], ev2: CanFail[Throwable], trace: Trace): ZClient[Env, In, Err, Out]

Attributes

Inherited from:
ZClient
final def get(pathSuffix: String)(implicit trace: Trace, ev: Body <:< Body): ZIO[Env, Err, Out]

Attributes

Inherited from:
ZClient
final def get(pathSuffix: String, body: Body)(implicit trace: Trace): ZIO[Env, Err, Out]

Attributes

Inherited from:
ZClient
final def hasContentType(value: CharSequence): Boolean

Attributes

Inherited from:
HeaderChecks

Attributes

Inherited from:
HeaderChecks

Attributes

Inherited from:
HeaderChecks

Attributes

Inherited from:
HeaderChecks
final def hasHeader(name: CharSequence): Boolean

Attributes

Inherited from:
HeaderChecks

Attributes

Inherited from:
HeaderChecks

Attributes

Inherited from:
HeaderChecks

Attributes

Inherited from:
HeaderChecks

Attributes

Inherited from:
HeaderChecks

Attributes

Inherited from:
HeaderChecks
final def head(pathSuffix: String)(implicit trace: Trace, ev: Body <:< Body): ZIO[Env, Err, Out]

Attributes

Inherited from:
ZClient
final def head(pathSuffix: String, body: Body)(implicit trace: Trace): ZIO[Env, Err, Out]

Attributes

Inherited from:
ZClient

Gets a header or returns None if the header was not present or it could not be parsed

Gets a header or returns None if the header was not present or it could not be parsed

Attributes

Inherited from:
HeaderGetters

Gets a header. If the header is not present, returns None. If the header could not be parsed it returns the parsing error

Gets a header. If the header is not present, returns None. If the header could not be parsed it returns the parsing error

Attributes

Inherited from:
HeaderGetters

Attributes

Inherited from:
HeaderGetters
final def host(host: String): ZClient[Env, In, Err, Out]

Attributes

Inherited from:
ZClient
final def map[Out2](f: Response => Out2): ZClient[Env, In, Err, Out2]

Attributes

Inherited from:
ZClient
def mapError[Err2](f: Throwable => Err2): ZClient[Env, In, Err2, Out]

Attributes

Inherited from:
ZClient
final def mapZIO[Env1, Err1 >: Throwable, Out2](f: Response => ZIO[Env1, Err1, Out2]): ZClient[Env1, In, Err1, Out2]

Attributes

Inherited from:
ZClient
final def patch(pathSuffix: String, body: Body)(implicit trace: Trace): ZIO[Env, Err, Out]

Attributes

Inherited from:
ZClient
final def path(segment: String): ZClient[Env, In, Err, Out]

Attributes

Inherited from:
ZClient
final def port(port: Int): ZClient[Env, In, Err, Out]

Attributes

Inherited from:
ZClient
final def post(pathSuffix: String, body: Body)(implicit trace: Trace): ZIO[Env, Err, Out]

Attributes

Inherited from:
ZClient

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product
final def put(pathSuffix: String, body: Body)(implicit trace: Trace): ZIO[Env, Err, Out]

Attributes

Inherited from:
ZClient
def query(key: String, value: String): ZClient[Env, In, Err, Out]

Attributes

Inherited from:
ZClient

Gets the raw unparsed header value

Gets the raw unparsed header value

Attributes

Inherited from:
HeaderGetters
final def rawHeader(name: CharSequence): Option[String]

Gets the raw unparsed header value

Gets the raw unparsed header value

Attributes

Inherited from:
HeaderGetters

Attributes

Inherited from:
ZClient
final def removeHeader(name: String): A

Attributes

Inherited from:
HeaderModifier

Attributes

Inherited from:
HeaderModifier

Attributes

Inherited from:
HeaderModifier
final def request(request: Request)(implicit ev: Body <:< Body, trace: Trace): ZIO[Env, Err, Out]

Attributes

Inherited from:
ZClient
final def request(method: Method, pathSuffix: String, body: Body)(implicit trace: Trace): ZIO[Env, Err, Out]

Attributes

Inherited from:
ZClient
final def retry[Env1](policy: Schedule[Env1, Throwable, Any]): ZClient[Env1, In, Err, Out]

Attributes

Inherited from:
ZClient
final def scheme(scheme: Scheme): ZClient[Env, In, Err, Out]

Attributes

Inherited from:
ZClient
final def setHeaders(headers: Headers): A

Attributes

Inherited from:
HeaderModifier
final def socket[Env1](pathSuffix: String)(app: SocketApp[Env1])(implicit trace: Trace): ZIO[Env1 & Scope, Err, Out]

Attributes

Inherited from:
ZClient
final def ssl(ssl: ClientSSLConfig): ZClient[Env, In, Err, Out]

Attributes

Inherited from:
ZClient
override def updateHeaders(update: Headers => Headers): ZClient[Env, In, Err, Out]

Updates the current Headers with new one, using the provided update function passed.

Updates the current Headers with new one, using the provided update function passed.

Attributes

Definition Classes
Inherited from:
ZClient
final def uri(uri: URI): ZClient[Env, In, Err, Out]

Attributes

Inherited from:
ZClient
final def url(url: URL): ZClient[Env, In, Err, Out]

Attributes

Inherited from:
ZClient

Attributes

Inherited from:
HeaderModifier