-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A framework for declaratively writing curl based API tests
--   
--   Please see the README on Github at
--   <a>https://github.com/aviaviavi/curl-runnings#readme</a>
@package curl-runnings
@version 0.2.0


-- | This module specifies any utilities used by this package. At this
--   time, consider everything in this module to be private to the
--   curl-runnings package
module Testing.CurlRunnings.Internal
makeRed :: String -> String
makeGreen :: String -> String


-- | Data types for curl-runnings tests
module Testing.CurlRunnings.Types

-- | A wrapper type around a set of test cases. This is the top level spec
--   type that we parse a test spec file into
newtype CurlSuite
CurlSuite :: [CurlCase] -> CurlSuite

-- | A single curl test case, the basic foundation of a curl-runnings test.
data CurlCase
CurlCase :: String -> String -> HttpMethod -> Maybe Value -> Maybe JsonMatcher -> StatusCodeMatcher -> CurlCase

-- | The name of the test case
[name] :: CurlCase -> String

-- | The target url to test
[url] :: CurlCase -> String

-- | Berb to use for the request
[requestMethod] :: CurlCase -> HttpMethod

-- | Payload to send with the request, if any
[requestData] :: CurlCase -> Maybe Value

-- | The assertions to make on the response payload, if any
[expectData] :: CurlCase -> Maybe JsonMatcher

-- | Assertion about the status code returned by the target
[expectStatus] :: CurlCase -> StatusCodeMatcher

-- | A basic enum for supported HTTP verbs
data HttpMethod
GET :: HttpMethod
POST :: HttpMethod
PUT :: HttpMethod
PATCH :: HttpMethod
DELETE :: HttpMethod

-- | A predicate to apply to the json body from the response
data JsonMatcher

-- | Performs <a>==</a>
Exactly :: Value -> JsonMatcher

-- | A list of matchers to make assertions about some subset of the
--   response.
Contains :: [JsonSubExpr] -> JsonMatcher

-- | A matcher for a subvalue of a json payload
data JsonSubExpr

-- | 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.
ValueMatch :: Value -> JsonSubExpr

-- | Assert the key value pair can be found somewhere the json.
KeyValueMatch :: Text -> Value -> JsonSubExpr
[matchKey] :: JsonSubExpr -> Text
[matchValue] :: JsonSubExpr -> Value

-- | Check the status code of a response. You can specify one or many valid
--   codes.
data StatusCodeMatcher
ExactCode :: Int -> StatusCodeMatcher
AnyCodeIn :: [Int] -> StatusCodeMatcher

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

-- | 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.
DataFailure :: CurlCase -> JsonMatcher -> (Maybe Value) -> AssertionFailure

-- | The status code we got back was wrong
StatusFailure :: CurlCase -> Int -> AssertionFailure

-- | Something else
UnexpectedFailure :: AssertionFailure

-- | A type representing the result of a single curl, and all associated
--   assertions
data CaseResult
CasePass :: CurlCase -> CaseResult
CaseFail :: CurlCase -> [AssertionFailure] -> CaseResult

-- | Simple predicate that checks if the result is passing
isPassing :: CaseResult -> Bool

-- | Simple predicate that checks if the result is failing
isFailing :: CaseResult -> Bool
instance GHC.Generics.Generic Testing.CurlRunnings.Types.CurlSuite
instance GHC.Show.Show Testing.CurlRunnings.Types.CurlSuite
instance GHC.Generics.Generic Testing.CurlRunnings.Types.CurlCase
instance GHC.Show.Show Testing.CurlRunnings.Types.CurlCase
instance GHC.Generics.Generic Testing.CurlRunnings.Types.StatusCodeMatcher
instance GHC.Show.Show Testing.CurlRunnings.Types.StatusCodeMatcher
instance GHC.Generics.Generic Testing.CurlRunnings.Types.JsonMatcher
instance GHC.Show.Show Testing.CurlRunnings.Types.JsonMatcher
instance GHC.Generics.Generic Testing.CurlRunnings.Types.JsonSubExpr
instance GHC.Show.Show Testing.CurlRunnings.Types.JsonSubExpr
instance GHC.Generics.Generic Testing.CurlRunnings.Types.HttpMethod
instance GHC.Show.Show Testing.CurlRunnings.Types.HttpMethod
instance Data.Aeson.Types.FromJSON.FromJSON Testing.CurlRunnings.Types.CurlSuite
instance Data.Aeson.Types.ToJSON.ToJSON Testing.CurlRunnings.Types.CurlSuite
instance GHC.Show.Show Testing.CurlRunnings.Types.CaseResult
instance GHC.Show.Show Testing.CurlRunnings.Types.AssertionFailure
instance Data.Aeson.Types.FromJSON.FromJSON Testing.CurlRunnings.Types.CurlCase
instance Data.Aeson.Types.ToJSON.ToJSON Testing.CurlRunnings.Types.CurlCase
instance Data.Aeson.Types.ToJSON.ToJSON Testing.CurlRunnings.Types.StatusCodeMatcher
instance Data.Aeson.Types.FromJSON.FromJSON Testing.CurlRunnings.Types.StatusCodeMatcher
instance Data.Aeson.Types.ToJSON.ToJSON Testing.CurlRunnings.Types.JsonMatcher
instance Data.Aeson.Types.FromJSON.FromJSON Testing.CurlRunnings.Types.JsonMatcher
instance Data.Aeson.Types.FromJSON.FromJSON Testing.CurlRunnings.Types.JsonSubExpr
instance Data.Aeson.Types.ToJSON.ToJSON Testing.CurlRunnings.Types.JsonSubExpr
instance Data.Aeson.Types.FromJSON.FromJSON Testing.CurlRunnings.Types.HttpMethod
instance Data.Aeson.Types.ToJSON.ToJSON Testing.CurlRunnings.Types.HttpMethod


-- | curl-runnings is a framework for writing declaratively writing curl
--   based tests for your API's. Write your test specifications with yaml
--   or json, and you're done!
module Testing.CurlRunnings

-- | Run a single test case, and returns the result. IO is needed here
--   since this method is responsible for actually curling the test case
--   endpoint and parsing the result.
runCase :: CurlCase -> IO CaseResult

-- | Runs the test cases in order and stop when an error is hit. Returns
--   all the results
runSuite :: CurlSuite -> IO [CaseResult]

-- | decode a json or yaml file into a suite object
decodeFile :: FilePath -> IO (Either String CurlSuite)
