dormouse-client-0.1.0.1: Simple, type-safe and testable HTTP client
Safe HaskellNone
LanguageHaskell2010

Dormouse.Client.Test.Class

Description

This module is useful for testing by providing a concrete ByteString typed version of MonadDormouseClient called MonadDormouseTestClient.

The assumption is that, in most test cases, you probably want to verify the byte payload of the request (which you simply extract from the request here as a ByteString) and provide a byte payload (also as a ByteString) in the response so that you can verify your repsonse payload can be decoded directly.

An implementation of MonadDormouseTestClient can be written in terms of either Strict or Lazy Bytestrings at your convenient and the other will be automatically provided for you.

The machinery in here uses orphan instances of MonadDormouseClient so you should use this carefully and restrict this module to test cases only.

Synopsis

Documentation

class Monad m => MonadDormouseTestClient m where Source #

MonadDormouseTestClient describes the capability to send and receive specifically ByteString typed HTTP Requests and Responses

Minimal complete definition

expectLbs | expectBs

Methods

expectLbs :: HttpRequest scheme method ByteString contentTag acceptTag -> m (HttpResponse ByteString) Source #

Make the supplied HTTP request, expecting an HTTP response with a Lazy ByteString body to be delivered in some MonadDormouseTest m

expectBs :: HttpRequest scheme method ByteString contentTag acceptTag -> m (HttpResponse ByteString) Source #

Make the supplied HTTP request, expecting an HTTP response with a Strict ByteString body to be delivered in some MonadDormouseTest m

Orphan instances

(Monad m, MonadIO m, MonadDormouseTestClient m) => MonadDormouseClient m Source # 
Instance details

Methods

send :: forall url (method :: Symbol) contentTag acceptTag b. IsUrl url => HttpRequest url method RawRequestPayload contentTag acceptTag -> (HttpResponse (SerialT IO Word8) -> IO (HttpResponse b)) -> m (HttpResponse b) Source #