mirror of
https://github.com/ilyakooo0/servant-quickcheck.git
synced 2024-11-25 02:58:12 +03:00
Support for servant-0.13
This commit is contained in:
parent
35bd148037
commit
d46b7183ad
43
.travis.yml
43
.travis.yml
@ -1,6 +1,6 @@
|
||||
# This Travis job script has been generated by a script via
|
||||
#
|
||||
# make_travis_yml_2.hs '--branch' 'master' '-o' '.travis.yml' 'servant-quickcheck.cabal'
|
||||
# runghc make_travis_yml_2.hs '--branch' 'master' '-o' '.travis.yml' 'servant-quickcheck.cabal'
|
||||
#
|
||||
# For more information, see https://github.com/hvr/multi-ghc-travis
|
||||
#
|
||||
@ -28,6 +28,8 @@ before_cache:
|
||||
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
|
||||
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx
|
||||
|
||||
- rm -rfv $HOME/.cabal/packages/head.hackage
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- compiler: "ghc-7.10.3"
|
||||
@ -36,15 +38,19 @@ matrix:
|
||||
- compiler: "ghc-8.0.2"
|
||||
# env: TEST=--disable-tests BENCH=--disable-benchmarks
|
||||
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.2], sources: [hvr-ghc]}}
|
||||
- compiler: "ghc-8.2.1"
|
||||
- compiler: "ghc-8.2.2"
|
||||
# env: TEST=--disable-tests BENCH=--disable-benchmarks
|
||||
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.1], sources: [hvr-ghc]}}
|
||||
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.2], sources: [hvr-ghc]}}
|
||||
|
||||
before_install:
|
||||
- HC=${CC}
|
||||
- HCPKG=${HC/ghc/ghc-pkg}
|
||||
- unset CC
|
||||
- PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH
|
||||
- ROOTDIR=$(pwd)
|
||||
- mkdir -p $HOME/.local/bin
|
||||
- "PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$HOME/local/bin:$PATH"
|
||||
- HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') ))
|
||||
- echo $HCNUMVER
|
||||
|
||||
install:
|
||||
- cabal --version
|
||||
@ -53,12 +59,15 @@ install:
|
||||
- TEST=${TEST---enable-tests}
|
||||
- HADDOCK=${HADDOCK-true}
|
||||
- INSTALLED=${INSTALLED-true}
|
||||
- GHCHEAD=${GHCHEAD-false}
|
||||
- travis_retry cabal update -v
|
||||
- sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
|
||||
- rm -fv cabal.project.local
|
||||
- "echo 'packages: .' > cabal.project"
|
||||
- "sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config"
|
||||
- rm -fv cabal.project cabal.project.local
|
||||
- grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'
|
||||
- "printf 'packages: \".\"\\n' > cabal.project"
|
||||
- cat cabal.project
|
||||
- if [ -f "./configure.ac" ]; then
|
||||
(cd "."; autoreconf -i);
|
||||
(cd "." && autoreconf -i);
|
||||
fi
|
||||
- rm -f cabal.project.freeze
|
||||
- cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all
|
||||
@ -70,26 +79,28 @@ install:
|
||||
# any command which exits with a non-zero exit code causes the build to fail.
|
||||
script:
|
||||
# test that source-distributions can be generated
|
||||
- (cd "."; cabal sdist)
|
||||
- (cd "." && cabal sdist)
|
||||
- mv "."/dist/servant-quickcheck-*.tar.gz ${DISTDIR}/
|
||||
- cd ${DISTDIR}
|
||||
- cd ${DISTDIR} || false
|
||||
- find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
|
||||
- "printf 'packages: servant-quickcheck-*/*.cabal\n' > cabal.project"
|
||||
- "printf 'packages: servant-quickcheck-*/*.cabal\\n' > cabal.project"
|
||||
- cat cabal.project
|
||||
# this builds all libraries and executables (without tests/benchmarks)
|
||||
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
|
||||
|
||||
# Build with installed constraints for packages in global-db
|
||||
- if $INSTALLED; then
|
||||
echo cabal new-build -w ${HC} --disable-tests --disable-benchmarks $(${HCPKG} list --global --simple-output --names-only | sed 's/\([a-zA-Z0-9-]\{1,\}\) */--constraint="\1 installed" /g') all | sh;
|
||||
else echo "Not building with installed constraints"; fi
|
||||
- if $INSTALLED; then echo cabal new-build -w ${HC} --disable-tests --disable-benchmarks $(${HCPKG} list --global --simple-output --names-only | sed 's/\([a-zA-Z0-9-]\{1,\}\) */--constraint="\1 installed" /g') all | sh; else echo "Not building with installed constraints"; fi
|
||||
|
||||
# build & run tests, build benchmarks
|
||||
- cabal new-build -w ${HC} ${TEST} ${BENCH} all
|
||||
- if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} all; fi
|
||||
- if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} ${BENCH} all; fi
|
||||
|
||||
# cabal check
|
||||
- (cd servant-quickcheck-* && cabal check)
|
||||
|
||||
# haddock
|
||||
- rm -rf ./dist-newstyle
|
||||
- if $HADDOCK; then cabal new-haddock -w ${HC} --disable-tests --disable-benchmarks all; else echo "Skipping haddock generation";fi
|
||||
- if $HADDOCK; then cabal new-haddock -w ${HC} ${TEST} ${BENCH} all; else echo "Skipping haddock generation";fi
|
||||
|
||||
# REGENDATA ["--branch","master","-o",".travis.yml","servant-quickcheck.cabal"]
|
||||
# EOF
|
||||
|
@ -2,6 +2,14 @@ upcoming:
|
||||
|
||||
releases:
|
||||
|
||||
- version: "0.0.6.0"
|
||||
changes:
|
||||
|
||||
- description: Support for servant-0.12
|
||||
issue: none
|
||||
authors: phadej
|
||||
date: 2018-02-09
|
||||
|
||||
- version: "0.0.5.0"
|
||||
changes:
|
||||
|
||||
|
31
example/Main.hs
Normal file
31
example/Main.hs
Normal file
@ -0,0 +1,31 @@
|
||||
{-# LANGUAGE OverloadedStrings, DataKinds #-}
|
||||
module Main (main) where
|
||||
|
||||
import Servant
|
||||
import Servant.QuickCheck
|
||||
import Test.Hspec
|
||||
import Data.Text (Text)
|
||||
import System.Environment (getArgs)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
args <- getArgs
|
||||
case args of
|
||||
[] -> putStrLn "Not running without arguments. Try --help or --fail-fast."
|
||||
_ -> hspec spec
|
||||
|
||||
-- Change to String to reproduce
|
||||
-- https://github.com/haskell-servant/servant-quickcheck/issues/41
|
||||
type API = Get '[PlainText] Text
|
||||
|
||||
api :: Proxy API
|
||||
api = Proxy
|
||||
|
||||
server :: Server API
|
||||
server = return "Sigurð Fáfnirslayer"
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "example server" $
|
||||
it "mangles UTF-8 in error messages" $
|
||||
withServantServer api (return server) $ \burl ->
|
||||
serverSatisfies api burl defaultArgs (getsHaveCacheControlHeader <%> mempty)
|
@ -1,5 +1,5 @@
|
||||
name: servant-quickcheck
|
||||
version: 0.0.5.0
|
||||
version: 0.0.6.0
|
||||
synopsis: QuickCheck entire APIs
|
||||
description:
|
||||
This packages provides QuickCheck properties that are tested across an entire
|
||||
@ -17,7 +17,7 @@ extra-source-files:
|
||||
tested-with:
|
||||
GHC==7.10.3,
|
||||
GHC==8.0.2,
|
||||
GHC==8.2.1
|
||||
GHC==8.2.2
|
||||
|
||||
source-repository head
|
||||
type: git
|
||||
@ -45,14 +45,14 @@ library
|
||||
, hspec >= 2.2 && < 2.5
|
||||
, http-client >= 0.4.30 && < 0.6
|
||||
, http-media >= 0.6 && <0.8
|
||||
, http-types > 0.8 && < 0.11
|
||||
, http-types > 0.8 && < 0.13
|
||||
, mtl > 2.1 && < 2.3
|
||||
, pretty == 1.1.*
|
||||
, process >= 1.2 && < 1.7
|
||||
, QuickCheck > 2.7 && < 2.11
|
||||
, servant > 0.6 && < 0.13
|
||||
, servant-client > 0.6 && < 0.13
|
||||
, servant-server > 0.6 && < 0.13
|
||||
, QuickCheck > 2.7 && < 2.12
|
||||
, servant >= 0.13 && < 0.14
|
||||
, servant-client >= 0.13 && < 0.14
|
||||
, servant-server >= 0.13 && < 0.14
|
||||
, split == 0.2.*
|
||||
, string-conversions > 0.3 && < 0.5
|
||||
, temporary == 1.2.*
|
||||
@ -114,3 +114,17 @@ test-suite spec
|
||||
, ScopedTypeVariables
|
||||
if flag(long-tests)
|
||||
cpp-options: -DLONG_TESTS
|
||||
|
||||
test-suite example
|
||||
type: exitcode-stdio-1.0
|
||||
main-is: Main.hs
|
||||
hs-source-dirs:
|
||||
example
|
||||
ghc-options: -Wall
|
||||
build-depends:
|
||||
base
|
||||
, hspec
|
||||
, servant-server
|
||||
, servant-quickcheck
|
||||
, text
|
||||
default-language: Haskell2010
|
||||
|
@ -78,7 +78,7 @@ instance HasGenRequest api => HasGenRequest (Description d :> api) where
|
||||
#endif
|
||||
|
||||
instance (Arbitrary c, HasGenRequest b, ToHttpApiData c )
|
||||
=> HasGenRequest (Capture x c :> b) where
|
||||
=> HasGenRequest (Capture' mods x c :> b) where
|
||||
genRequest _ = (oldf, do
|
||||
old' <- old
|
||||
new' <- toUrlPiece <$> new
|
||||
@ -101,10 +101,10 @@ instance (Arbitrary c, HasGenRequest b, ToHttpApiData c )
|
||||
#endif
|
||||
|
||||
instance (Arbitrary c, KnownSymbol h, HasGenRequest b, ToHttpApiData c)
|
||||
=> HasGenRequest (Header h c :> b) where
|
||||
=> HasGenRequest (Header' mods h c :> b) where
|
||||
genRequest _ = (oldf, do
|
||||
old' <- old
|
||||
new' <- toUrlPiece <$> new
|
||||
new' <- toUrlPiece <$> new -- TODO: generate lenient or/and optional
|
||||
return $ \burl -> let r = old' burl in r {
|
||||
requestHeaders = (hdr, cs new') : requestHeaders r })
|
||||
where
|
||||
@ -113,9 +113,9 @@ instance (Arbitrary c, KnownSymbol h, HasGenRequest b, ToHttpApiData c)
|
||||
new = arbitrary :: Gen c
|
||||
|
||||
instance (AllMimeRender x c, Arbitrary c, HasGenRequest b)
|
||||
=> HasGenRequest (ReqBody x c :> b) where
|
||||
=> HasGenRequest (ReqBody' mods x c :> b) where
|
||||
genRequest _ = (oldf, do
|
||||
old' <- old
|
||||
old' <- old -- TODO: generate lenient
|
||||
new' <- new
|
||||
(ct, bd) <- elements $ allMimeRender (Proxy :: Proxy x) new'
|
||||
return $ \burl -> let r = old' burl in r {
|
||||
@ -127,9 +127,9 @@ instance (AllMimeRender x c, Arbitrary c, HasGenRequest b)
|
||||
new = arbitrary :: Gen c
|
||||
|
||||
instance (KnownSymbol x, Arbitrary c, ToHttpApiData c, HasGenRequest b)
|
||||
=> HasGenRequest (QueryParam x c :> b) where
|
||||
=> HasGenRequest (QueryParam' mods x c :> b) where
|
||||
genRequest _ = (oldf, do
|
||||
new' <- new
|
||||
new' <- new -- TODO: generate lenient or/and optional
|
||||
old' <- old
|
||||
return $ \burl -> let r = old' burl
|
||||
newExpr = param <> "=" <> cs (toQueryParam new')
|
||||
|
Loading…
Reference in New Issue
Block a user