-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Test framework for HTTP APIs -- -- A simple framework for making assertions about the responses of HTTP -- servers. -- --
-- import Test.HTTP
-- import Data.List (isInfixOf)
--
-- main = httpTest $ do
-- session "BayesHive landing page" "https://bayeshive.com" $ do
-- landing <- get "/"
-- assert "Correct blog link" $
-- "href=\"https://bayeshive.com/blog\"" `isInfixOf` landing
-- loginResult <- postForm "/auth/page/email/login"
-- [("email", "foo"), ("password", "bar")]
-- debug loginResult
--
@package http-test
@version 0.1.4
module Test.HTTP
-- | Run one or more test sessions. httpTest will exit when done, with exit
-- code 1 if there were failures
httpTest :: Program () -> IO ()
-- | Define a single test session based on session name and base url
session :: String -> String -> Session () -> Program ()
-- | GET a web page as a String
get :: String -> Session String
-- | GET a JSON value
getJSON :: FromJSON a => String -> Session a
-- | perform an action with a JSON value from a GET
withJSON :: FromJSON a => String -> (a -> Session ()) -> Session ()
-- | Post a form
postForm :: String -> [(String, String)] -> Session String
-- | make an assertion
assert :: String -> Bool -> Session ()
-- | assert equality, for better output messages
assertEq :: (Show a, Eq a) => String -> a -> a -> Session ()
-- | make an assertion in the Parser monad, ofr use with JSON value
assertParse :: String -> Parser Bool -> Session ()
-- | Output a string to stdout if --verbose is in command line
-- arguments
debug :: String -> Session ()
type Program = ReaderT (TVar [Results]) IO
type Session a = StateT SessionState (ErrorT String IO) a