Safe Haskell | None |
---|
Test.HTTP
- httpTest :: Program () -> IO ()
- session :: String -> Url -> Session () -> Program ()
- get :: Url -> Session String
- getJSON :: FromJSON a => Url -> Session a
- withJSON :: FromJSON a => String -> (a -> Session ()) -> Session ()
- post :: Url -> [String] -> Session String
- postForm :: Url -> [(String, String)] -> Session String
- postJSON :: (ToJSON a, FromJSON b) => Url -> a -> Session b
- assert :: String -> Bool -> Session ()
- assertEq :: (Show a, Eq a) => String -> a -> a -> Session ()
- assertParse :: String -> Parser Bool -> Session ()
- failTest :: MonadState SessionState m => String -> String -> m ()
- debug :: String -> Session ()
- type Program = ReaderT (TVar [Results]) IO
- type Session a = StateT SessionState (ErrorT String IO) a
Documentation
httpTest :: Program () -> IO ()Source
Run one or more test sessions. httpTest will exit when done, with exit code 1 if there were failures
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
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
Arguments
:: String | assertion name (used for reporting failures |
-> Bool | Boolean of which we are asserting truth |
-> Session () |
make an assertion
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
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