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 #

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 #

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

Instances
Show CaseResult # 
Instance details

Defined in Testing.CurlRunnings.Types

newtype CurlSuite #

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] 
Instances
Show CurlSuite # 
Instance details

Defined in Testing.CurlRunnings.Types

Generic CurlSuite # 
Instance details

Defined in Testing.CurlRunnings.Types

Associated Types

type Rep CurlSuite :: * -> * #

ToJSON CurlSuite # 
Instance details

Defined in Testing.CurlRunnings.Types

FromJSON CurlSuite # 
Instance details

Defined in Testing.CurlRunnings.Types

type Rep CurlSuite # 
Instance details

Defined in Testing.CurlRunnings.Types

type Rep CurlSuite = D1 (MetaData "CurlSuite" "Testing.CurlRunnings.Types" "curl-runnings-0.6.0-Fzf6jPTaR0CKz1zGRtBbdh" True) (C1 (MetaCons "CurlSuite" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [CurlCase])))

data CurlCase #

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

Constructors

CurlCase 

Fields

Instances
Show CurlCase # 
Instance details

Defined in Testing.CurlRunnings.Types

Generic CurlCase # 
Instance details

Defined in Testing.CurlRunnings.Types

Associated Types

type Rep CurlCase :: * -> * #

Methods

from :: CurlCase -> Rep CurlCase x #

to :: Rep CurlCase x -> CurlCase #

ToJSON CurlCase # 
Instance details

Defined in Testing.CurlRunnings.Types

FromJSON CurlCase # 
Instance details

Defined in Testing.CurlRunnings.Types

type Rep CurlCase # 
Instance details

Defined in Testing.CurlRunnings.Types

data Header #

A representation of a single header

Constructors

Header Text Text 
Instances
Show Header # 
Instance details

Defined in Testing.CurlRunnings.Types

Generic Header # 
Instance details

Defined in Testing.CurlRunnings.Types

Associated Types

type Rep Header :: * -> * #

Methods

from :: Header -> Rep Header x #

to :: Rep Header x -> Header #

ToJSON Header # 
Instance details

Defined in Testing.CurlRunnings.Types

type Rep Header # 
Instance details

Defined in Testing.CurlRunnings.Types

type Rep Header = D1 (MetaData "Header" "Testing.CurlRunnings.Types" "curl-runnings-0.6.0-Fzf6jPTaR0CKz1zGRtBbdh" False) (C1 (MetaCons "Header" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text)))

data HeaderMatcher #

Collection of matchers to run against a single curl response

Instances
Show HeaderMatcher # 
Instance details

Defined in Testing.CurlRunnings.Types

Generic HeaderMatcher # 
Instance details

Defined in Testing.CurlRunnings.Types

Associated Types

type Rep HeaderMatcher :: * -> * #

ToJSON HeaderMatcher # 
Instance details

Defined in Testing.CurlRunnings.Types

FromJSON HeaderMatcher # 
Instance details

Defined in Testing.CurlRunnings.Types

type Rep HeaderMatcher # 
Instance details

Defined in Testing.CurlRunnings.Types

type Rep HeaderMatcher = D1 (MetaData "HeaderMatcher" "Testing.CurlRunnings.Types" "curl-runnings-0.6.0-Fzf6jPTaR0CKz1zGRtBbdh" False) (C1 (MetaCons "HeaderMatcher" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [PartialHeaderMatcher])))

data Headers #

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

Constructors

HeaderSet [Header] 
Instances
Show Headers # 
Instance details

Defined in Testing.CurlRunnings.Types

Generic Headers # 
Instance details

Defined in Testing.CurlRunnings.Types

Associated Types

type Rep Headers :: * -> * #

Methods

from :: Headers -> Rep Headers x #

to :: Rep Headers x -> Headers #

ToJSON Headers # 
Instance details

Defined in Testing.CurlRunnings.Types

FromJSON Headers # 
Instance details

Defined in Testing.CurlRunnings.Types

type Rep Headers # 
Instance details

Defined in Testing.CurlRunnings.Types

type Rep Headers = D1 (MetaData "Headers" "Testing.CurlRunnings.Types" "curl-runnings-0.6.0-Fzf6jPTaR0CKz1zGRtBbdh" False) (C1 (MetaCons "HeaderSet" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Header])))

data HttpMethod #

A basic enum for supported HTTP verbs

Constructors

GET 
POST 
PUT 
PATCH 
DELETE 
Instances
Show HttpMethod # 
Instance details

Defined in Testing.CurlRunnings.Types

Generic HttpMethod # 
Instance details

Defined in Testing.CurlRunnings.Types

Associated Types

type Rep HttpMethod :: * -> * #

ToJSON HttpMethod # 
Instance details

Defined in Testing.CurlRunnings.Types

FromJSON HttpMethod # 
Instance details

Defined in Testing.CurlRunnings.Types

type Rep HttpMethod # 
Instance details

Defined in Testing.CurlRunnings.Types

type Rep HttpMethod = D1 (MetaData "HttpMethod" "Testing.CurlRunnings.Types" "curl-runnings-0.6.0-Fzf6jPTaR0CKz1zGRtBbdh" 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 #

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.

Instances
Show JsonMatcher # 
Instance details

Defined in Testing.CurlRunnings.Types

Generic JsonMatcher # 
Instance details

Defined in Testing.CurlRunnings.Types

Associated Types

type Rep JsonMatcher :: * -> * #

ToJSON JsonMatcher # 
Instance details

Defined in Testing.CurlRunnings.Types

FromJSON JsonMatcher # 
Instance details

Defined in Testing.CurlRunnings.Types

type Rep JsonMatcher # 
Instance details

Defined in Testing.CurlRunnings.Types

type Rep JsonMatcher = D1 (MetaData "JsonMatcher" "Testing.CurlRunnings.Types" "curl-runnings-0.6.0-Fzf6jPTaR0CKz1zGRtBbdh" False) (C1 (MetaCons "Exactly" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Value)) :+: C1 (MetaCons "Contains" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [JsonSubExpr])))

data JsonSubExpr #

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

Instances
Show JsonSubExpr # 
Instance details

Defined in Testing.CurlRunnings.Types

Generic JsonSubExpr # 
Instance details

Defined in Testing.CurlRunnings.Types

Associated Types

type Rep JsonSubExpr :: * -> * #

ToJSON JsonSubExpr # 
Instance details

Defined in Testing.CurlRunnings.Types

FromJSON JsonSubExpr # 
Instance details

Defined in Testing.CurlRunnings.Types

type Rep JsonSubExpr # 
Instance details

Defined in Testing.CurlRunnings.Types

type Rep JsonSubExpr = D1 (MetaData "JsonSubExpr" "Testing.CurlRunnings.Types" "curl-runnings-0.6.0-Fzf6jPTaR0CKz1zGRtBbdh" False) (C1 (MetaCons "ValueMatch" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Value)) :+: C1 (MetaCons "KeyValueMatch" PrefixI True) (S1 (MetaSel (Just "matchKey") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text) :*: S1 (MetaSel (Just "matchValue") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Value)))

data PartialHeaderMatcher #

Specify a key, value, or both to match against in the returned headers of a response.

data StatusCodeMatcher #

Check the status code of a response. You can specify one or many valid codes.

Constructors

ExactCode Int 
AnyCodeIn [Int] 

data QueryError #

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

Instances
Show QueryError # 
Instance details

Defined in Testing.CurlRunnings.Types

data Index #

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
Show Index # 
Instance details

Defined in Testing.CurlRunnings.Types

Methods

showsPrec :: Int -> Index -> ShowS #

show :: Index -> String #

showList :: [Index] -> ShowS #

data Query #

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
Show Query # 
Instance details

Defined in Testing.CurlRunnings.Types

Methods

showsPrec :: Int -> Query -> ShowS #

show :: Query -> String #

showList :: [Query] -> ShowS #

data InterpolatedQuery #

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 #

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

type SingleQueryText = Text #

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 #

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

Constructors

CurlRunningsState Environment [CaseResult] LogLevel 

isFailing :: CaseResult -> Bool #

Simple predicate that checks if the result is failing

isPassing :: CaseResult -> Bool #

Simple predicate that checks if the result is passing