From f327a093800ede1c32a3238d3ee62d0b875849cc Mon Sep 17 00:00:00 2001 From: Nicolas BACQUEY Date: Thu, 8 Dec 2022 16:39:12 +0100 Subject: [PATCH 1/2] Support servant-server-0.19.1 Since version 0.19.1, `servant-server` requires the type `a` in combinator `Capture foo a` to be `Typeable`. This commit adds the constraint in `HasMock` for `Capture'` and `CaptureAll` --- servant-mock.cabal | 6 +++--- src/Servant/Mock.hs | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/servant-mock.cabal b/servant-mock.cabal index efc1b74..f5163cf 100644 --- a/servant-mock.cabal +++ b/servant-mock.cabal @@ -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 @@ -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 diff --git a/src/Servant/Mock.hs b/src/Servant/Mock.hs index edffc25..5bdb71c 100644 --- a/src/Servant/Mock.hs +++ b/src/Servant/Mock.hs @@ -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 @@ -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)) @@ -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) From 6b2398f649db4e476107c6ab80595366d733c7ff Mon Sep 17 00:00:00 2001 From: Nicolas BACQUEY Date: Mon, 9 Jan 2023 11:34:35 +0100 Subject: [PATCH 2/2] update stack config --- stack.yaml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/stack.yaml b/stack.yaml index b416708..04d3074 100644 --- a/stack.yaml +++ b/stack.yaml @@ -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