git.iko.soy/typeable/servant
on master help sign in
add ComprehensiveAPI to test whether we're missing instances

Some of the combinators are commented atm, because we *are* missing combinators.

commite5974ec94d33bd6fce3a993a00ea2500eb67177b authorSönke Hahn <soenkehahn@gmail.com> dateSat 16 Jan 2016, 19:17 (11 years ago) parentb8d70e3
9 files changed+92−1
servant-client/test/Servant/ClientSpec.hs+3 servant-docs/test/Servant/DocsSpec.hs+17−1 servant-js/test/Servant/JSSpec.hs+7 servant-mock/servant-mock.cabal+15 servant-mock/test/Servant/MockSpec.hs+12 servant-mock/test/Spec.hs+1 servant-server/test/Servant/ServerSpec.hs+4 servant/servant.cabal+1 servant/src/Servant/API/Internal/Test/ComprehensiveAPI.hs+32
servant-client/test/Servant/ClientSpec.hs+3
@@ -49,9 +49,12 @@ import Test.HUnit
4949import Test.QuickCheck
5050
5151import Servant.API
52+import Servant.API.Internal.Test.ComprehensiveAPI
5253import Servant.Client
5354import Servant.Server
5455
56+_ = client comprehensiveAPI
57+
5558spec :: Spec
5659spec = describe "Servant.Client" $ do
5760 sucessSpec
servant-docs/test/Servant/DocsSpec.hs+17−1
@@ -1,7 +1,7 @@
11{-# LANGUAGE DataKinds #-}
22{-# LANGUAGE DeriveGeneric #-}
3−{-# LANGUAGE FlexibleInstances #-}
43{-# LANGUAGE FlexibleContexts #-}
4+{-# LANGUAGE FlexibleInstances #-}
55{-# LANGUAGE MultiParamTypeClasses #-}
66{-# LANGUAGE OverloadedStrings #-}
77{-# LANGUAGE TypeOperators #-}
@@ -18,8 +18,24 @@ import GHC.Generics
1818import Test.Hspec
1919
2020import Servant.API
21+import Servant.API.Internal.Test.ComprehensiveAPI
2122import Servant.Docs.Internal
2223
24+-- * comprehensive api
25+
26+_ = docs comprehensiveAPI
27+
28+instance ToParam (QueryParam "foo" Int) where
29+ toParam = error "unused"
30+instance ToParam (QueryParams "foo" Int) where
31+ toParam = error "unused"
32+instance ToParam (QueryFlag "foo") where
33+ toParam = error "unused"
34+instance ToCapture (Capture "foo" Int) where
35+ toCapture = error "unused"
36+
37+-- * specs
38+
2339spec :: Spec
2440spec = describe "Servant.Docs" $ do
2541
servant-js/test/Servant/JSSpec.hs+7
@@ -21,6 +21,7 @@ import qualified Data.Text as T
2121import Language.ECMAScript3.Parser (program, parse)
2222import Test.Hspec hiding (shouldContain, shouldNotContain)
2323
24+import Servant.API.Internal.Test.ComprehensiveAPI
2425import Servant.JS
2526import Servant.JS.Internal
2627import qualified Servant.JS.Angular as NG
@@ -29,6 +30,12 @@ import qualified Servant.JS.JQuery as JQ
2930import qualified Servant.JS.Vanilla as JS
3031import Servant.JSSpec.CustomHeaders
3132
33+-- * comprehensive api
34+
35+_ = (jsForAPI comprehensiveAPI vanillaJS :: Text)
36+
37+-- * specs
38+
3239type TestAPI = "simple" :> ReqBody '[JSON,FormUrlEncoded] Text :> Post '[JSON] Bool
3340 :<|> "has.extension" :> Get '[FormUrlEncoded,JSON] Bool
3441
servant-mock/servant-mock.cabal+15
@@ -45,3 +45,18 @@ executable mock-app
4545 buildable: True
4646 else
4747 buildable: False
48+
49+test-suite spec
50+ type: exitcode-stdio-1.0
51+ ghc-options:
52+ -Wall -fno-warn-name-shadowing
53+ default-language: Haskell2010
54+ hs-source-dirs: test
55+ main-is: Spec.hs
56+ other-modules:
57+ Servant.MockSpec
58+ build-depends:
59+ base,
60+ hspec,
61+ servant,
62+ servant-mock
servant-mock/test/Servant/MockSpec.hsnew file+12
@@ -0,0 +1,12 @@
1+
2+module Servant.MockSpec where
3+
4+import Test.Hspec
5+
6+import Servant.API.Internal.Test.ComprehensiveAPI
7+import Servant.Mock
8+
9+_ = mock comprehensiveAPI
10+
11+spec :: Spec
12+spec = return ()
servant-mock/test/Spec.hsnew file+1
@@ -0,0 +1 @@
1+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
servant-server/test/Servant/ServerSpec.hs+4
@@ -46,6 +46,7 @@ import Servant.API ((:<|>) (..), (:>), Capture, Delete,
4646 QueryFlag, QueryParam, QueryParams,
4747 Raw, RemoteHost, ReqBody,
4848 StdMethod (..), Verb, addHeader)
49+import Servant.API.Internal.Test.ComprehensiveAPI
4950import Servant.Server (ServantErr (..), Server, err404,
5051 serve)
5152import Test.Hspec (Spec, context, describe, it,
@@ -60,6 +61,9 @@ import Servant.Server.Internal.Router
6061 (tweakResponse, runRouter,
6162 Router, Router'(LeafRouter))
6263
64+-- * comprehensive api test
65+
66+_ = serve comprehensiveAPI (error "unused") (error "unused")
6367
6468-- * Specs
6569
servant/servant.cabal+1
@@ -31,6 +31,7 @@ library
3131 Servant.API.ContentTypes
3232 Servant.API.Header
3333 Servant.API.HttpVersion
34+ Servant.API.Internal.Test.ComprehensiveAPI
3435 Servant.API.IsSecure
3536 Servant.API.QueryParam
3637 Servant.API.Raw
servant/src/Servant/API/Internal/Test/ComprehensiveAPI.hsnew file+32
@@ -0,0 +1,32 @@
1+{-# LANGUAGE DataKinds #-}
2+{-# LANGUAGE TypeOperators #-}
3+
4+module Servant.API.Internal.Test.ComprehensiveAPI where
5+
6+import Data.Proxy
7+
8+import Servant.API
9+
10+type GET = Get '[JSON] ()
11+
12+type ComprehensiveAPI =
13+ GET :<|>
14+ Get '[JSON] Int :<|>
15+ Capture "foo" Int :> GET :<|>
16+ Header "foo" Int :> GET :<|>
17+-- HttpVersion :> GET :<|>
18+ IsSecure :> GET :<|>
19+ QueryParam "foo" Int :> GET :<|>
20+ QueryParams "foo" Int :> GET :<|>
21+ QueryFlag "foo" :> GET :<|>
22+-- Raw :<|>
23+-- RemoteHost :<|>
24+ ReqBody '[JSON] Int :> GET :<|>
25+-- Get '[JSON] (Headers '[Header "foo" Int] ()) :<|>
26+ "foo" :> GET :<|>
27+ Vault :> GET :<|>
28+ Verb 'POST 204 '[JSON] () :<|>
29+ Verb 'POST 204 '[JSON] Int
30+
31+comprehensiveAPI :: Proxy ComprehensiveAPI
32+comprehensiveAPI = Proxy