Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support servant-server-0.19.1 #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions servant-mock.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: >=1.10
name: servant-mock
version: 0.8.7
version: 0.8.8

synopsis: Derive a mock server for free from your servant API types
category: Servant, Web, Testing
Expand Down Expand Up @@ -43,8 +43,8 @@ library
base-compat >=0.10.5 && <0.12,
bytestring >=0.10.8.1 && <0.11,
http-types >=0.12.2 && <0.13,
servant >=0.17 && <0.19,
servant-server >=0.17 && <0.19,
servant >=0.17 && <0.20,
servant-server >=0.17 && <0.20,
transformers >=0.5.2.0 && <0.6,
QuickCheck >=2.12.6.1 && <2.14,
wai >=3.2.1.2 && <3.3
Expand Down
12 changes: 10 additions & 2 deletions src/Servant/Mock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import Prelude.Compat
import Control.Monad.IO.Class
import Data.ByteString.Lazy.Char8 (pack)
import Data.Proxy
import Data.Typeable (Typeable)
import GHC.TypeLits
import Network.HTTP.Types.Status
import Network.Wai
Expand Down Expand Up @@ -118,10 +119,10 @@ instance (HasMock a context, HasMock b context) => HasMock (a :<|> b) context wh
instance (KnownSymbol path, HasMock rest context) => HasMock (path :> rest) context where
mock _ = mock (Proxy :: Proxy rest)

instance (KnownSymbol s, FromHttpApiData a, HasMock rest context, SBoolI (FoldLenient mods)) => HasMock (Capture' mods s a :> rest) context where
instance (KnownSymbol s, FromHttpApiData a, Typeable a, HasMock rest context, SBoolI (FoldLenient mods)) => HasMock (Capture' mods s a :> rest) context where
mock _ context = \_ -> mock (Proxy :: Proxy rest) context

instance (KnownSymbol s, FromHttpApiData a, HasMock rest context) => HasMock (CaptureAll s a :> rest) context where
instance (KnownSymbol s, FromHttpApiData a, Typeable a, HasMock rest context) => HasMock (CaptureAll s a :> rest) context where
mock _ context = \_ -> mock (Proxy :: Proxy rest) context

instance (AllCTUnrender ctypes a, HasMock rest context, SBoolI (FoldLenient mods))
Expand Down Expand Up @@ -226,6 +227,13 @@ instance ( HasContextEntry context (NamedContext name subContext)

mock _ _ = mock (Proxy :: Proxy rest) (Proxy :: Proxy subContext)

instance ( HasMock api context
, AtLeastOneFragment api
, FragmentUnique (Fragment a :> api)
) =>
HasMock (Fragment a :> api) context where
mock _ context = mock (Proxy :: Proxy api) context

mockArbitrary :: (MonadIO m, Arbitrary a) => m a
mockArbitrary = liftIO (generate arbitrary)

Expand Down
10 changes: 2 additions & 8 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
resolver: nightly-2016-10-07
resolver: lts-20.5
packages:
- '.'
extra-deps:
- hspec-wai-0.8.0
- hspec-expectations-0.8.0
- call-stack-0.1.0
- hspec-2.3.1
- hspec-discover-2.3.1
- hspec-core-2.3.1
flags: {}
extra-package-dbs: []
allow-newer: true