integration-0.1.0
Safe HaskellNone
LanguageGHC2021

Testlib.Assertions

Synopsis

Documentation

shouldMatch Source #

Arguments

:: (MakesValue a, MakesValue b, HasCallStack) 
=> a

The actual value

-> b

The expected value

-> App () 

eventually :: App a -> App a Source #

Retries every 100ms until timeOutSeconds from Env is reached

shouldMatchWithMsg Source #

Arguments

:: (MakesValue a, MakesValue b, HasCallStack) 
=> Maybe String

Message to be added to failure report

-> a

The actual value

-> b

The expected value

-> App () 

data LenientMatchRule Source #

Instances

Instances details
Bounded LenientMatchRule Source # 
Instance details

Defined in Testlib.Assertions

Enum LenientMatchRule Source # 
Instance details

Defined in Testlib.Assertions

Show LenientMatchRule Source # 
Instance details

Defined in Testlib.Assertions

Eq LenientMatchRule Source # 
Instance details

Defined in Testlib.Assertions

Ord LenientMatchRule Source # 
Instance details

Defined in Testlib.Assertions

shouldMatchBase64 Source #

Arguments

:: (MakesValue a, HasCallStack) 
=> a

The actual value, in base64

-> ByteString

The expected value

-> App () 

shouldNotMatch Source #

Arguments

:: (MakesValue a, MakesValue b, HasCallStack) 
=> a

The actual value

-> b

The un-expected value

-> App () 

shouldMatchInt Source #

Arguments

:: (MakesValue a, HasCallStack) 
=> a

The actual value

-> Int

The expected value

-> App () 

Specialized variant of shouldMatch to avoid the need for type annotations.

shouldNotMatchInt Source #

Arguments

:: (MakesValue a, HasCallStack) 
=> a

The actual value

-> Int

The expected value

-> App () 

shouldMatchRange Source #

Arguments

:: (MakesValue a, HasCallStack) 
=> a

The actual value

-> (Int, Int)

The expected range, inclusive both sides

-> App () 

shouldMatchSet :: (MakesValue a, MakesValue b, HasCallStack) => a -> b -> App () Source #

Match on sorted lists (sets where elements may occur more than once). (Maybe this should be called shouldMatchMultiSet?)

data Shape Source #

A simple DSL for describing the recursive structure (shape) of a JSON value. Use shouldMatchShape to assert that a value conforms to a shape, or valueShape to compute the shape of an existing value.

Object matching is strict: any key present in the actual value but absent from the expected SObject field list causes an assertion failure.

FUTUREWORK: heterogenous arrays (`["yes", true, 3]`) FUTUREWORK: optional attributes

Instances

Instances details
Show Shape Source # 
Instance details

Defined in Testlib.Assertions

Methods

showsPrec :: Int -> Shape -> ShowS #

show :: Shape -> String #

showList :: [Shape] -> ShowS #

shouldMatchShape Source #

Arguments

:: (MakesValue a, HasCallStack) 
=> a

The actual value

-> Shape

The expected shape

-> App () 

Assert that actual conforms to shape. Provides a JSON-path-like location in the failure message (e.g. .assets[0].key).

matchShape :: String -> Value -> Shape -> Maybe String Source #

Internal recursive shape-matcher. Returns Nothing on success and Just errorMessage on failure. The path argument accumulates the JSON-path-like location prefix.

matchShapeLoc :: String -> String Source #

Format a path for use in error messages, using the document root ($) when the path is empty.

valueShape :: MakesValue a => a -> App Shape Source #

Compute the Shape of an existing JSON value. Useful for inspecting what shape a response actually has, or for using a known-good response as a shape template via shouldMatchShape.

Arrays: if the array is empty the element shape is SAny; otherwise the shape of the first element is used for all elements.

shouldContainString Source #

Arguments

:: HasCallStack 
=> String

The actual value

-> String

The expected value

-> App () 

shouldContain Source #

Arguments

:: (Eq a, Show a, HasCallStack) 
=> [a]

The actual value

-> [a]

The expected value

-> App () 

shouldNotContain Source #

Arguments

:: (Eq a, Show a, HasCallStack) 
=> [a]

The actual value

-> [a]

The expected value

-> App ()