-- 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 = defaultMain $ httpTestCase "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.2.5
module Test.HTTP
httpTestCase :: String -> Url -> Session () -> TestTree
-- | GET a web page as a String
get :: Url -> Session String
-- | GET a JSON value
getJSON :: FromJSON a => Url -> Session a
-- | perform an action with a JSON value from a GET
withJSON :: FromJSON a => String -> (a -> Session ()) -> Session ()
-- | Post a string body
post :: Url -> String -> Session String
-- | Post a JSON value
postJSON :: (ToJSON a, FromJSON b) => Url -> a -> Session b
-- | Post a form
postForm :: Url -> [(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, for 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 Session = StateT HttpTest IO
type Url = String
-- | Parse the command line arguments and run the tests
defaultMain :: TestTree -> IO ()
-- | Re-start the timer
tic :: Session ()
-- | Print the number of seconds elapsed, with a prefix
toc :: String -> Session Double