Skip to content

Commit 269432b

Browse files
authored
Merge pull request #1735 from haskell-servant/migration-servant-quickcheck
2 parents ef4b38a + 7010d83 commit 269432b

34 files changed

+3351
-0
lines changed

servant-quickcheck/.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake . -Lv
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: haskell ci
2+
on:
3+
push:
4+
pull_request:
5+
workflow_dispatch:
6+
jobs:
7+
generate-matrix:
8+
name: "Generate matrix from cabal"
9+
outputs:
10+
matrix: ${{ steps.set-matrix.outputs.matrix }}
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Extract the tested GHC versions
14+
id: set-matrix
15+
uses: kleidukos/[email protected]
16+
with:
17+
cabal-file: servant-quickcheck.cabal
18+
ubuntu-version: latest
19+
macos-version: latest
20+
windows-version: latest
21+
version: 0.1.7.0
22+
tests:
23+
name: ${{ matrix.ghc }} on ${{ matrix.os }}
24+
needs: generate-matrix
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: haskell-actions/setup@v2
31+
id: setup-haskell
32+
with:
33+
ghc-version: ${{ matrix.ghc }}
34+
- name: Cache
35+
uses: actions/[email protected]
36+
with:
37+
path: ${{ steps.setup-haskell.outputs.cabal-store }}
38+
key: ${{ matrix.os }}-ghc-${{ matrix.ghc }}-cabal-${{ hashFiles('**/plan.json') }}
39+
restore-keys: ${{ matrix.os }}-ghc-${{ matrix.ghc }}-
40+
- run: cabal test all
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: nix ci
2+
on:
3+
push:
4+
pull_request:
5+
workflow_dispatch:
6+
jobs:
7+
build:
8+
permissions:
9+
contents: read
10+
id-token: write
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: DeterminateSystems/nix-installer-action@main
15+
- uses: DeterminateSystems/magic-nix-cache-action@main
16+
- run: nix -L flake check
17+
- run: nix -L build .#servant-quickcheck
18+
- run: nix -L build .#ghc94-servant-quickcheck
19+
- run: nix -L build .#ghc98-servant-quickcheck

servant-quickcheck/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
doc/_build/
2+
scripts/
3+
samples/
4+
test-servers/
5+
/doc/
6+
.stack-work/
7+
.pre-commit-config.yaml
8+
.direnv
9+
dist*
10+
result*

servant-quickcheck/CHANGELOG.yaml

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
releases:
2+
- version: "0.1.0.0"
3+
changes:
4+
- description: "Support servant{-server,-client} up to 0.20, support base up to 4.19, drop support for some older servant and base versions, drop support for stack, drop testing for some older ghc versions"
5+
authors: mangoiv
6+
date: 2024-04-02
7+
- version: "0.0.9.0"
8+
changes:
9+
- description: "Support servant-0.15 (#65)"
10+
authors: fizruk
11+
date: 2020-06-25
12+
13+
- description: "Relax constraints for GHC 8.10 (#70)"
14+
authors: felixmulder
15+
date: 2020-06-20
16+
17+
- version: "0.0.8.0"
18+
changes:
19+
- description: Support for servant-0.17
20+
authors: phadej
21+
date: 2019-01-23
22+
23+
- version: "0.0.7.3"
24+
changes:
25+
- description: Support for servant-0.14
26+
issue: 53
27+
authors: phadej
28+
date: 2018-06-12
29+
30+
- description: Fix a failure from OnlyJsonObjects when there is no content-type.
31+
issue: 55
32+
authors: Phenitei
33+
date: 2018-08-27
34+
35+
- description: A bug fix where notAllowedContainsAllowHeader would print the initial request alongside the failure instead of the request causing the failure when it failed.
36+
issue: 57
37+
authors: Phenitei
38+
date: 2018-08-29
39+
40+
- description: QuickCheck 2.12 compatibility
41+
issue: 58
42+
authors: parsonsmatt
43+
date: 2018-10-12
44+
45+
- description: GHC 8.6 compatibility
46+
issue: 59
47+
authors: phadej
48+
date: 2018-10-15
49+
50+
- version: "0.0.7.2"
51+
changes:
52+
53+
- description: Allow client to pass an HTTP Manager in to functions
54+
issue: 47
55+
authors: parsonsmatt
56+
date: 2018-05-10
57+
58+
- description: Fix "should not happen" error when exceptions are thrown
59+
issue: 48
60+
authors: parsonsmatt
61+
date: 2018-05-10
62+
63+
- version: "0.0.7.0"
64+
changes:
65+
66+
- description: Support for base-compat-0.10
67+
issue: none
68+
authors: phadej
69+
date: 2018-04-12
70+
71+
- version: "0.0.7.0"
72+
changes:
73+
74+
- description: Support for GHC-8.4.1
75+
issue: none
76+
authors: phadej
77+
date: 2018-03-23
78+
79+
- description: Requires hspec-2.5
80+
issue: none
81+
authors: phadej
82+
date: 2018-03-23
83+
84+
- version: "0.0.6.0"
85+
changes:
86+
87+
- description: Support for servant-0.12
88+
issue: none
89+
authors: phadej
90+
date: 2018-02-09
91+
92+
- version: "0.0.5.0"
93+
changes:
94+
95+
- description: Export forgotten predicates
96+
issue: none
97+
pr: 40
98+
authors: Phenitei
99+
date: 2017-12-14
100+
101+
- version: "0.0.4"
102+
changes:
103+
104+
- description: Support for Servant 0.12
105+
issue: none
106+
authors: phadej
107+
date: 2017-11-07
108+
109+
- description: Support for Servant 0.11
110+
issue: none
111+
pr: 32
112+
authors: adinapoli-iohk
113+
date: 2017-10-18
114+
notes: Includes 0-weighted instance for EmptyAPI
115+
116+
- version: "0.0.3.0"
117+
changes:
118+
119+
- description: Add jsonEquality
120+
issue: 2
121+
pr: 30
122+
authors: erewok
123+
date: 2017-10-15
124+
125+
- description: Support hspec >= 2.4
126+
issue: 27
127+
pr: 29
128+
authors: erewok, jkarni
129+
date: 2017-10-15
130+
131+
- version: "0.0.2.4"
132+
changes:
133+
134+
- description: Don't append slashes to paths
135+
issue: 22
136+
authors: declension
137+
date: 2017-03-11
138+
139+
- version: "0.0.2.3"
140+
changes:
141+
142+
- description: Fix QueryParam and QueryFlag requests
143+
issue: 23
144+
authors: declension
145+
date: 2017-03-10
146+
147+
- version: "0.0.2.2"
148+
changes:
149+
150+
- description: Make onlyJsonObjects succeed in non-JSON endpoints
151+
issue: 20
152+
authors: jkarni
153+
date: 2016-10-18
154+
155+
156+
- version: "0.0.2.1"
157+
changes:
158+
159+
- description: Add notLongerThan predicate
160+
pr: 17
161+
authors: jkarni
162+
date: 2016-10-05
163+
164+
- description: Add getsHaveLastModifiedHeader predicate
165+
pr: none
166+
authors: jkarni
167+
date: 2016-10-03
168+
169+
- description: Raise upper bounds
170+
notes: >
171+
For Quickcheck, aeson, http-client, servant, servant-client and
172+
servant-server.
173+
pr: none
174+
authors: jkarni
175+
date: 2016-10-03
176+
177+
178+
- version: "0.0.2.0"
179+
changes:
180+
181+
- description: Update CHANGELOG to YAML syntax.
182+
pr: 16
183+
authors: jkarni
184+
date: 2016-09-14
185+
186+
- description: Support new CaptureAll combinator
187+
pr: 16
188+
authors: jkarni
189+
date: 2016-09-14
190+
191+
- description: Support GHC 8
192+
pr: 16
193+
authors: jkarni
194+
date: 2016-09-14
195+
196+
- version: "0.0.1.1"
197+
changes:
198+
199+
- description: Exclude GHC 7.8 (by bumping base lower bound to 4.8)
200+
pr: none
201+
authors: jkarni
202+
203+
- description: More generous bounds for other packages.
204+
pr: none
205+
authors: jkarni
206+
207+
- version: "0.0.1.0"
208+
changes:
209+
210+
- description: Better error messages.
211+
notes: >
212+
Error messages now contain failing predicate, failing response and
213+
(except for response predicates), failing requests.
214+
pr: none
215+
authors: jkarni
216+
217+
- description: Signicant changes to RequestPredicate and ResponsePredicate types.
218+
pr: none
219+
authors: jkarni

servant-quickcheck/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# servant-quickcheck
2+
3+
`servant-quickcheck` provides tools to test properties across entire APIs.
4+
Rather than writing the same tests for each endpoint, with `servant-quickcheck`
5+
you can simply specify properties every endpoint must meet once and for all.
6+
For example:
7+
8+
``` haskell
9+
followsBestPractices :: Spec
10+
followsBestPractices = describe "my API" $ do
11+
12+
it "follows best practices" $ do
13+
withServantServer myAPI myServer $ \burl ->
14+
serverSatisfies api burl stdArgs
15+
( not500
16+
<%> onlyJsonObjects
17+
<%> getsHaveCacheControlHeader
18+
<%> headsHaveCacheControlHeader
19+
<%> mempty)
20+
```
21+
22+
Additionally, `servant-quickcheck` provides a `serversEqual` function that
23+
generates arbitrary requests (that conform to the description of an API) and
24+
tests that two servers respond identically to them. This can be useful when
25+
refactoring or rewriting an API that should not change.

servant-quickcheck/cabal.project

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
packages:
2+
./.
3+
4+
-- due to a bug in the nixpkgs haskell infrastructure (or cabal, if you will)
5+
-- it is impossible to provided hspec-discover in a devShell therefore having
6+
-- to resort to downloads from hackage
7+
repository hackage.haskell.org
8+
url: http://hackage.haskell.org/
9+
10+
tests: true
11+
12+
allow-newer: servant-blaze:servant
13+
14+
test-show-details: direct

servant-quickcheck/doc/Main.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import ServersEqual
2+
3+
main :: IO ()
4+
main = main1

0 commit comments

Comments
 (0)