http-test-0.1.6: Test framework for HTTP APIs

Safe HaskellNone

Test.HTTP

Synopsis

Documentation

httpTest :: Program () -> IO ()Source

Run one or more test sessions. httpTest will exit when done, with exit code 1 if there were failures

sessionSource

Arguments

:: String

Session name (used for logging failures)

-> Url

Base URL

-> Session ()

the actions and assertions that define the session

-> Program () 

Define a single test session based on session name and base url

getSource

Arguments

:: Url

URL

-> Session String 

GET a web page as a String

getJSONSource

Arguments

:: FromJSON a 
=> Url

URL

-> Session a 

GET a JSON value

withJSONSource

Arguments

:: FromJSON a 
=> String

URL

-> (a -> Session ())

action to perform on successfully decoded value

-> Session () 

perform an action with a JSON value from a GET

post :: Url -> [String] -> Session StringSource

Post a string body

postFormSource

Arguments

:: Url

URL

-> [(String, String)]

form fields

-> Session String 

Post a form

postJSON :: (ToJSON a, FromJSON b) => Url -> a -> Session bSource

Post a JSON value

assertSource

Arguments

:: String

assertion name (used for reporting failures

-> Bool

Boolean of which we are asserting truth

-> Session () 

make an assertion

assertEqSource

Arguments

:: (Show a, Eq a) 
=> String

assertion name (used for reporting failures

-> a

a value

-> a

what it is meant to be equal to

-> Session () 

assert equality, for better output messages

assertParseSource

Arguments

:: String

assertion name (used for reporting failures

-> Parser Bool

Boolean of which we are asserting truth

-> Session () 

make an assertion in the Parser monad, ofr use with JSON value

failTest :: MonadState SessionState m => String -> String -> m ()Source

debug :: String -> Session ()Source

Output a string to stdout if --verbose is in command line arguments

type Program = ReaderT (TVar [Results]) IOSource

type Session a = StateT SessionState (ErrorT String IO) aSource