Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data types for curl-runnings tests
- data AssertionFailure
- data CaseResult
- newtype CurlSuite = CurlSuite [CurlCase]
- data CurlCase = CurlCase {}
- data Header = Header Text Text
- data HeaderMatcher = HeaderMatcher [PartialHeaderMatcher]
- data Headers = HeaderSet [Header]
- data HttpMethod
- data JsonMatcher
- = Exactly Value
- | Contains [JsonSubExpr]
- data JsonSubExpr
- = ValueMatch Value
- | KeyValueMatch {
- matchKey :: Text
- matchValue :: Value
- data PartialHeaderMatcher = PartialHeaderMatcher (Maybe Text) (Maybe Text)
- data StatusCodeMatcher
- data QueryError
- data Index
- data Query
- data InterpolatedQuery
- type FullQueryText = Text
- type SingleQueryText = Text
- data CurlRunningsState = CurlRunningsState Environment [CaseResult] LogLevel
- isFailing :: CaseResult -> Bool
- isPassing :: CaseResult -> Bool
- logger :: CurlRunningsState -> CurlRunningsLogger
- unsafeLogger :: Show a => CurlRunningsState -> CurlRunningsUnsafeLogger a
Documentation
data AssertionFailure Source #
Represents the different type of test failures we can have. A single test case | might return many assertion failures.
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
A wrapper type around a set of test cases. This is the top level spec type that we parse a test spec file into
A single curl test case, the basic foundation of a curl-runnings test.
CurlCase | |
|
A representation of a single header
data HeaderMatcher Source #
Collection of matchers to run against a single curl response
Simple container for a list of headers, useful for a vehicle for defining a fromJSON
data HttpMethod Source #
A basic enum for supported HTTP verbs
data JsonMatcher Source #
A predicate to apply to the json body from the response
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
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. |
|
data PartialHeaderMatcher Source #
Specify a key, value, or both to match against in the returned headers of a response.
data StatusCodeMatcher Source #
Check the status code of a response. You can specify one or many valid codes.
data QueryError Source #
Different errors relating to querying json from previous test cases
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 |
A single lookup operation in a json query
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. |
A single entity to be queries from a json value
Query [Index] | A single query contains a list of discrete index operations |
EnvironmentVariable Text | Lookup a string in the environment |
data InterpolatedQuery Source #
A distinct parsed unit in a query
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
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
unsafeLogger :: Show a => CurlRunningsState -> CurlRunningsUnsafeLogger a Source #