Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Assert
provides ways to maintain claims over Response
s.
Synopsis
- data Assertions a
- class Contains a where
- (!!!) :: (HasCallStack, MonadIO m, MonadCatch m) => m (Response (Maybe ByteString)) -> Assertions () -> m ()
- (<!!) :: (HasCallStack, MonadIO m, MonadCatch m) => m (Response (Maybe ByteString)) -> Assertions () -> m (Response (Maybe ByteString))
- (===) :: (HasCallStack, Eq a, Show a) => (Response (Maybe ByteString) -> a) -> (Response (Maybe ByteString) -> a) -> Assertions ()
- (=/=) :: (HasCallStack, Eq a, Show a) => (Response (Maybe ByteString) -> a) -> (Response (Maybe ByteString) -> a) -> Assertions ()
- (=~=) :: (HasCallStack, Show a, Contains a) => (Response (Maybe ByteString) -> a) -> (Response (Maybe ByteString) -> a) -> Assertions ()
- assertResponse :: HasCallStack => (Response (Maybe ByteString) -> Maybe String) -> Assertions ()
- assertTrue :: HasCallStack => String -> (Response (Maybe ByteString) -> Bool) -> Assertions ()
- assertTrue_ :: HasCallStack => (Response (Maybe ByteString) -> Bool) -> Assertions ()
- assert :: HasCallStack => String -> Bool -> Assertions ()
- assert_ :: HasCallStack => Bool -> Assertions ()
Documentation
data Assertions a Source #
Instances
Applicative Assertions Source # | |
Defined in Bilge.Assert 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 # | |
Defined in Bilge.Assert fmap :: (a -> b) -> Assertions a -> Assertions b # (<$) :: a -> Assertions b -> Assertions a # | |
Monad Assertions Source # | |
Defined in Bilge.Assert (>>=) :: 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.
Instances
Contains ByteString Source # | |
Defined in Bilge.Assert contains :: ByteString -> ByteString -> Bool Source # | |
Contains ByteString Source # | |
Defined in Bilge.Assert contains :: ByteString -> ByteString -> Bool Source # | |
Contains a => Contains (Maybe a) Source # | |
Eq a => Contains [a] Source # | |
Defined in Bilge.Assert |
(!!!) :: (HasCallStack, MonadIO m, MonadCatch m) => m (Response (Maybe ByteString)) -> Assertions () -> m () infixr 3 Source #
(<!!) :: (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.