bilge-0.22.0: Library for composing HTTP requests.
Safe HaskellSafe-Inferred
LanguageGHC2021

Bilge.Assert

Description

Assert provides ways to maintain claims over Responses.

Synopsis

Documentation

data Assertions a Source #

A Writer monad containing the list of assertions as predicate functions of a Response.

Instances

Instances details
Applicative Assertions Source # 
Instance details

Defined in Bilge.Assert

Methods

pure :: a -> Assertions a #

(<*>) :: Assertions (a -> b) -> Assertions a -> Assertions b #

liftA2 :: (a -> b -> c) -> Assertions a -> Assertions b -> Assertions c #

(*>) :: Assertions a -> Assertions b -> Assertions b #

(<*) :: Assertions a -> Assertions b -> Assertions a #

Functor Assertions Source # 
Instance details

Defined in Bilge.Assert

Methods

fmap :: (a -> b) -> Assertions a -> Assertions b #

(<$) :: a -> Assertions b -> Assertions a #

Monad Assertions Source # 
Instance details

Defined in Bilge.Assert

Methods

(>>=) :: Assertions a -> (a -> Assertions b) -> Assertions b #

(>>) :: Assertions a -> Assertions b -> Assertions b #

return :: a -> Assertions a #

class Contains a where Source #

Type-class the denote a containment relation.

Methods

contains :: a -> a -> Bool Source #

If True, the first argument is contained in the second.

Instances

Instances details
Contains ByteString Source # 
Instance details

Defined in Bilge.Assert

Contains ByteString Source # 
Instance details

Defined in Bilge.Assert

Contains a => Contains (Maybe a) Source # 
Instance details

Defined in Bilge.Assert

Methods

contains :: Maybe a -> Maybe a -> Bool Source #

Eq a => Contains [a] Source # 
Instance details

Defined in Bilge.Assert

Methods

contains :: [a] -> [a] -> Bool Source #

(!!!) :: (HasCallStack, MonadIO m, MonadCatch m) => m (Response (Maybe ByteString)) -> Assertions () -> m () infixr 3 Source #

Like <!! but discards the Response.

(<!!) :: (HasCallStack, MonadIO m, MonadCatch m) => m (Response (Maybe ByteString)) -> Assertions () -> m (Response (Maybe ByteString)) infixr 3 Source #

Given an IO action to get a Response and a set of assertions, evaluate all assertions against the response. This function prints an error message for every assertion that fails (N.B. assertions are enumerated, i.e. you will see the index of the assertion that failed). It will also return the response, so it can be used for further inspection.

(===) :: (HasCallStack, Eq a, Show a) => (Response (Maybe ByteString) -> a) -> (Response (Maybe ByteString) -> a) -> Assertions () infix 4 Source #

Tests the assertion that the left-hand side and the right-hand side are equal. If not, actual values will be printed.

(=/=) :: (HasCallStack, Eq a, Show a) => (Response (Maybe ByteString) -> a) -> (Response (Maybe ByteString) -> a) -> Assertions () infix 4 Source #

Tests the assertion that the left-hand side and the right-hand side are not equal. If not, actual values will be printed.

(=~=) :: (HasCallStack, Show a, Contains a) => (Response (Maybe ByteString) -> a) -> (Response (Maybe ByteString) -> a) -> Assertions () Source #

Tests the assertion that the left-hand side is contained in the right-hand side. If not, actual values will be printed.

assertResponse :: HasCallStack => (Response (Maybe ByteString) -> Maybe String) -> Assertions () Source #

Most generic assertion on a request. If the test function evaluates to (Just msg) then the assertion fails with the error message msg.

assertTrue :: HasCallStack => String -> (Response (Maybe ByteString) -> Bool) -> Assertions () Source #

Generic assertion on a request. The String argument will be printed in case the assertion fails.

assertTrue_ :: HasCallStack => (Response (Maybe ByteString) -> Bool) -> Assertions () Source #

Generic assertion on a request.

assert :: HasCallStack => String -> Bool -> Assertions () Source #

Generic assertion inside the Assertions monad. The String argument will be printed in case the assertion fails.

assert_ :: HasCallStack => Bool -> Assertions () Source #

Generic assertion inside the Assertions monad.