tasty-wai-0.1.1.0: Test 'wai' endpoints via Test.Tasty

Safe HaskellNone
LanguageHaskell2010

Test.Tasty.Wai

Contents

Description

Types and functions for testing wai endpoints using the tasty testing framework.

Synopsis

Types

data Sess Source #

Data structure for carrying around the info needed to build and run a test.

Constructors

S Application TestName (Session ()) 
Instances
IsTest Sess Source # 
Instance details

Defined in Test.Tasty.Wai

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

get :: ByteString -> Session SResponse Source #

Submit a GET request to the provided endpoint.

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.