curl-runnings-0.6.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

QueryFailure CurlCase QueryError

Something went wrong with a test case json query

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.6.0-3VEecZgLaJkBPXRG6TV7RA" 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.6.0-3VEecZgLaJkBPXRG6TV7RA" 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.6.0-3VEecZgLaJkBPXRG6TV7RA" 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

data QueryError Source #

Different errors relating to querying json from previous test cases

Constructors

QueryParseError Text Text

The query was malformed and couldn't be parsed

QueryTypeMismatch Text Value

The retrieved a value of the wrong type or was otherwise operating on the wrong type of thing

QueryValidationError Text

The query was parse-able

NullPointer Text Text

Tried to access a value in a null object

data Index Source #

A single lookup operation in a json query

Constructors

CaseResultIndex Integer

Drill into the json of a specific test case. The SUITE object is accessible as an array of values that have come back from previous test cases

KeyIndex Text

A standard json key lookup.

ArrayIndex Integer

A standard json array index lookup.

Instances

data Query Source #

A single entity to be queries from a json value

Constructors

Query [Index]

A single query contains a list of discrete index operations

EnvironmentVariable Text

Lookup a string in the environment

Instances

data InterpolatedQuery Source #

A distinct parsed unit in a query

Constructors

LiteralText Text

Regular text, no query

InterpolatedQuery Text Query

Some leading text, then a query

NonInterpolatedQuery Query

Just a query, no leading text

type FullQueryText = Text Source #

The full string in which a query appears, eg "prefix-${{SUITE[0].key.another_key[0].last_key}}"

type SingleQueryText = Text Source #

The string for one query given the FullQueryText above, the single query text would be SUITE[0].key.another_key[0].last_key

data CurlRunningsState Source #

The state of a suite. Tracks environment variables, and all the test results so far

Constructors

CurlRunningsState Environment [CaseResult] LogLevel 

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