Safe Haskell | None |
---|---|
Language | Haskell2010 |
Types and functions for testing wai
endpoints using the tasty
testing framework.
Synopsis
- data Sess = S Application TestName (Session ())
- testWai :: Application -> TestName -> Session () -> TestTree
- get :: ByteString -> Session SResponse
- post :: ByteString -> ByteString -> Session SResponse
- put :: ByteString -> ByteString -> Session SResponse
- assertStatus' :: Status -> SResponse -> Session ()
- buildRequest :: StdMethod -> ByteString -> Request
- buildRequestWithBody :: StdMethod -> ByteString -> ByteString -> SRequest
- buildRequestWithHeaders :: StdMethod -> ByteString -> ByteString -> RequestHeaders -> SRequest
- module Network.Wai.Test
Types
Data structure for carrying around the info needed to build and run a test.
S Application TestName (Session ()) |
Creation
testWai :: Application -> TestName -> Session () -> TestTree Source #
Run a test case against a Application
.
This module re-exports the functions from 'wai-extra' for constructing the
Session
that is executed against a given endpoint.
A small test case may look like:
import MyApp (app) testWai app "List Topics" $ do res <- get "fudge/view" assertStatus' HTTP.status200 res
Helpers
post :: ByteString -> ByteString -> Session SResponse Source #
Submit a POST
request to the given endpoint with the provided
ByteString
as the body content.
put :: ByteString -> ByteString -> Session SResponse Source #
Submit a PUT
request to the given endpoint with the provided
ByteString
as the body content.
assertStatus' :: Status -> SResponse -> Session () Source #
An alternative helper function for checking the status code on a response
that lets you use the functions from Types
as opposed to bare
numbers.
Request Builders
buildRequest :: StdMethod -> ByteString -> Request Source #
Create an empty Request
using the given HTTP Method and route.
buildRequestWithBody :: StdMethod -> ByteString -> ByteString -> SRequest Source #
As per buildRequest
but requires body content.
buildRequestWithHeaders :: StdMethod -> ByteString -> ByteString -> RequestHeaders -> SRequest Source #
As per buildRequestWithBody
but allows for the setting of RequestHeaders
.
module Network.Wai.Test