curl-runnings-0.3.0: A framework for declaratively writing curl based API tests

Safe HaskellNone
LanguageHaskell2010

Testing.CurlRunnings.Types

Description

Data types for curl-runnings tests

Synopsis

Documentation

data AssertionFailure Source #

Represents the different type of test failures we can have. A single test case | might return many assertion failures.

Constructors

DataFailure CurlCase JsonMatcher (Maybe Value)

The json we got back was wrong. We include this redundant field (it's included in the CurlCase field above) in order to enforce at the type level that we have to be expecting some data in order to have this type of failure.

StatusFailure CurlCase Int

The status code we got back was wrong

HeaderFailure CurlCase HeaderMatcher Headers

The headers we got back were wrong

UnexpectedFailure

Something else

data CaseResult Source #

A type representing the result of a single curl, and all associated assertions

newtype CurlSuite Source #

A wrapper type around a set of test cases. This is the top level spec type that we parse a test spec file into

Constructors

CurlSuite [CurlCase] 

data CurlCase Source #

A single curl test case, the basic foundation of a curl-runnings test.

Constructors

CurlCase 

Fields

Instances

Show CurlCase Source # 
Generic CurlCase Source # 

Associated Types

type Rep CurlCase :: * -> * #

Methods

from :: CurlCase -> Rep CurlCase x #

to :: Rep CurlCase x -> CurlCase #

ToJSON CurlCase Source # 
FromJSON CurlCase Source # 
type Rep CurlCase Source # 

data Header Source #

A representation of a single header

Constructors

Header Text Text 

Instances

Show Header Source # 
Generic Header Source # 

Associated Types

type Rep Header :: * -> * #

Methods

from :: Header -> Rep Header x #

to :: Rep Header x -> Header #

ToJSON Header Source # 
type Rep Header Source # 
type Rep Header = D1 * (MetaData "Header" "Testing.CurlRunnings.Types" "curl-runnings-0.3.0-8Iz6UIUQXlZ5UNmPAk9tWL" False) (C1 * (MetaCons "Header" PrefixI False) ((:*:) * (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Text)) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Text))))

data Headers Source #

Simple container for a list of headers, useful for a vehicle for defining a fromJSON

Constructors

HeaderSet [Header] 

Instances

Show Headers Source # 
Generic Headers Source # 

Associated Types

type Rep Headers :: * -> * #

Methods

from :: Headers -> Rep Headers x #

to :: Rep Headers x -> Headers #

ToJSON Headers Source # 
FromJSON Headers Source # 
type Rep Headers Source # 
type Rep Headers = D1 * (MetaData "Headers" "Testing.CurlRunnings.Types" "curl-runnings-0.3.0-8Iz6UIUQXlZ5UNmPAk9tWL" False) (C1 * (MetaCons "HeaderSet" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * [Header])))

data HttpMethod Source #

A basic enum for supported HTTP verbs

Constructors

GET 
POST 
PUT 
PATCH 
DELETE 

Instances

Show HttpMethod Source # 
Generic HttpMethod Source # 

Associated Types

type Rep HttpMethod :: * -> * #

ToJSON HttpMethod Source # 
FromJSON HttpMethod Source # 
type Rep HttpMethod Source # 
type Rep HttpMethod = D1 * (MetaData "HttpMethod" "Testing.CurlRunnings.Types" "curl-runnings-0.3.0-8Iz6UIUQXlZ5UNmPAk9tWL" False) ((:+:) * ((:+:) * (C1 * (MetaCons "GET" PrefixI False) (U1 *)) (C1 * (MetaCons "POST" PrefixI False) (U1 *))) ((:+:) * (C1 * (MetaCons "PUT" PrefixI False) (U1 *)) ((:+:) * (C1 * (MetaCons "PATCH" PrefixI False) (U1 *)) (C1 * (MetaCons "DELETE" PrefixI False) (U1 *)))))

data JsonMatcher Source #

A predicate to apply to the json body from the response

Constructors

Exactly Value

Performs ==

Contains [JsonSubExpr]

A list of matchers to make assertions about some subset of the response.

data JsonSubExpr Source #

A matcher for a subvalue of a json payload

Constructors

ValueMatch Value

Assert some value anywhere in the json has a value equal to a given value. The motivation for this field is largely for checking contents of a top level array. It's also useful if you don't know the key ahead of time.

KeyValueMatch

Assert the key value pair can be found somewhere the json.

Fields

isFailing :: CaseResult -> Bool Source #

Simple predicate that checks if the result is failing

isPassing :: CaseResult -> Bool Source #

Simple predicate that checks if the result is passing