git.iko.soy/servant-quickcheck
on b3a7b64 help sign in
67 lines 2.5 kB history raw
1-- | @Servant.QuickCheck@ provides utilities related to using QuickCheck over an API.
2-- Rather than specifying properties that individual handlers must satisfy,
3-- you can state properties that ought to hold true of the entire API.
4--
5-- While the API must be described with @servant@ types, the server being
6-- tested itself need not be implemented with @servant-server@ (or indeed,
7-- written in Haskell).
8--
9-- The documentation of the <#useful-preds Useful predicates> sections is
10-- meant to serve as a set of helpful pointers for learning more about best
11-- practices concerning REST APIs.
12module Servant.QuickCheck
13 (
15 -- * Property testing
16 serverSatisfies
17 -- ** Predicates
18 -- *** #useful-preds# Useful predicates
19 -- | The predicates below are often useful. Some check RFC compliance; some are
20 -- best practice, and some are useful to check that APIs follow in-house
21 -- best-practices. Included in the documentation for each is a list of
22 -- references to any relevant RFCs and other links, as well as what type of
23 -- predicate it is (__RFC Compliance__, __Best Practice__, __Optional__).
24 --
25 -- RFCs distinguish between the force of requirements (e.g. __MUST__ vs.
26 -- __SHOULD__). __RFC Compliance__ includes any absolute requirements present
27 -- in RFCs. The __Best Practices__ includes, in addition to RFC
28 -- recommendations, recommendations found elsewhere or generally accepted.
29 , not500
30 , onlyJsonObjects
31 , notAllowedContainsAllowHeader
32 , unauthorizedContainsWWWAuthenticate
33 , getsHaveCacheControlHeader
34 , headsHaveCacheControlHeader
35 -- *** Predicate utilities and types
36 , (<%>)
37 , Predicates
38 , ResponsePredicate(..)
39 , RequestPredicate(..)
41 -- * Equality testing
42 , serversEqual
43 -- ** Response equality
44 -- | Often the normal equality of responses is not what we want. For example,
45 -- if responses contain a @Date@ header with the time of the response,
46 -- responses will fail to be equal even though they morally are. This datatype
47 -- represents other means of checking equality
48 -- *** Useful @ResponseEquality@s
49 , bodyEquality
50 , allEquality
51 -- ** Response equality type
52 , ResponseEquality(..)
54 -- * Test setup helpers
55 -- | Helpers to setup and teardown @servant@ servers during tests.
56 , withServantServer
57 , withServantServerAndContext
59 -- ** Re-exports
60 , BaseUrl(..)
61 , Scheme(..)
64 ) where
66import Servant.QuickCheck.Internal
67import Servant.Client (BaseUrl(..), Scheme(..))