Network.Wai.Test

wai-extra-3.0.14.3: Provides some basic WAI handlers and middleware.

Safe Haskell | None
Language | Haskell98

Network.Wai.Test

Contents

- Session
- Client Cookies
- Requests
- Assertions

Synopsis

- type Session = ReaderT Application (StateT ClientState IO)
- runSession :: Session a -> Application -> IO a
- type ClientCookies = Map ByteString SetCookie
- getClientCookies :: Session ClientCookies
- modifyClientCookies :: (ClientCookies -> ClientCookies) -> Session ()
- setClientCookie :: SetCookie -> Session ()
- deleteClientCookie :: ByteString -> Session ()
- request :: Request -> Session SResponse
- srequest :: SRequest -> Session SResponse
- data SRequest = SRequest {
  - simpleRequest :: Request
  - simpleRequestBody :: ByteString
  }
- data SResponse = SResponse {
  - simpleStatus :: Status
  - simpleHeaders :: ResponseHeaders
  - simpleBody :: ByteString
  }
- defaultRequest :: Request
- setPath :: Request -> ByteString -> Request
- setRawPathInfo :: Request -> ByteString -> Request
- assertStatus :: Int -> SResponse -> Session ()
- assertContentType :: ByteString -> SResponse -> Session ()
- assertBody :: ByteString -> SResponse -> Session ()
- assertBodyContains :: ByteString -> SResponse -> Session ()
- assertHeader :: CI ByteString -> ByteString -> SResponse -> Session ()
- assertNoHeader :: CI ByteString -> SResponse -> Session ()
- assertClientCookieExists :: String -> ByteString -> Session ()
- assertNoClientCookieExists :: String -> ByteString -> Session ()
- assertClientCookieValue :: String -> ByteString -> ByteString -> Session ()
- data WaiTestFailure = WaiTestFailure String

# Session

type Session = ReaderT Application (StateT ClientState IO)

runSession :: Session a -> Application -> IO a

# Client Cookies

type ClientCookies = Map ByteString SetCookie

Since 3.0.6

getClientCookies :: Session ClientCookies

Since 3.0.6

modifyClientCookies :: (ClientCookies -> ClientCookies) -> Session ()

Since 3.0.6

setClientCookie :: SetCookie -> Session ()

Since 3.0.6

deleteClientCookie :: ByteString -> Session ()

Since 3.0.6

# Requests

request :: Request -> Session SResponse

srequest :: SRequest -> Session SResponse

data SRequest

Constructors

SRequest |
Fields simpleRequest :: Request simpleRequestBody :: ByteString

data SResponse

Constructors

SResponse |
Fields simpleStatus :: Status simpleHeaders :: ResponseHeaders simpleBody :: ByteString

Instances

Eq SResponse |
Show SResponse |

defaultRequest :: Request

A default, blank request.

Since 2.0.0

setPath :: Request -> ByteString -> Request

Set whole path (request path + query string).

setRawPathInfo :: Request -> ByteString -> Request

# Assertions

assertStatus :: Int -> SResponse -> Session ()

assertContentType :: ByteString -> SResponse -> Session ()

assertBody :: ByteString -> SResponse -> Session ()

assertBodyContains :: ByteString -> SResponse -> Session ()

assertHeader :: CI ByteString -> ByteString -> SResponse -> Session ()

assertNoHeader :: CI ByteString -> SResponse -> Session ()

assertClientCookieExists :: String -> ByteString -> Session ()

Since 3.0.6

assertNoClientCookieExists :: String -> ByteString -> Session ()

Since 3.0.6

assertClientCookieValue :: String -> ByteString -> ByteString -> Session ()

Since 3.0.6

data WaiTestFailure

Constructors

WaiTestFailure String |

Instances

Eq WaiTestFailure |
Show WaiTestFailure |
Exception WaiTestFailure |