http-test-0.2.5: Test framework for HTTP APIs

Safe HaskellNone
LanguageHaskell98

Test.HTTP

Synopsis

Documentation

httpTestCase Source

Arguments

:: String

Session name (used for logging failures)

-> Url

Base URL

-> Session ()

the actions and assertions that define the session

-> TestTree 

get Source

Arguments

:: Url

URL

-> Session String 

GET a web page as a String

getJSON Source

Arguments

:: FromJSON a 
=> Url

URL

-> Session a 

GET a JSON value

withJSON Source

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 String Source

Post a string body

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

Post a JSON value

postForm Source

Arguments

:: Url

URL

-> [(String, String)]

form fields

-> Session String 

Post a form

assert Source

Arguments

:: String

assertion name (used for reporting failures

-> Bool

Boolean of which we are asserting truth

-> Session () 

make an assertion

assertEq Source

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

assertParse Source

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, for use with JSON value

debug :: String -> Session () Source

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

type Session = StateT HttpTest IO Source

defaultMain :: TestTree -> IO ()

Parse the command line arguments and run the tests

tic :: Session () Source

Re-start the timer

toc :: String -> Session Double Source

Print the number of seconds elapsed, with a prefix