on master help sign in
Add ComprehensiVeAPI test for servant-foreign
da1b198Oleg Grenrus
servant-foreign/servant-foreign.cabal+1
@@ -67,6 +67,7 @@ test-suite spec
67 other-modules: Servant.ForeignSpec
67 other-modules: Servant.ForeignSpec
68 build-depends: base
68 build-depends: base
69 , hspec >= 2.1.8
69 , hspec >= 2.1.8
70+ , servant
70 , servant-foreign
71 , servant-foreign
71 default-language: Haskell2010
72 default-language: Haskell2010
72 default-extensions: ConstraintKinds
73 default-extensions: ConstraintKinds
servant-foreign/test/Servant/ForeignSpec.hs+9
@@ -6,9 +6,11 @@ module Servant.ForeignSpec where
6import Data.Monoid ((<>))
6import Data.Monoid ((<>))
7import Data.Proxy
7import Data.Proxy
8import Servant.Foreign
8import Servant.Foreign
9+import Servant.API.Internal.Test.ComprehensiveAPI
9
10
10import Test.Hspec
11import Test.Hspec
11
12
13+
12spec :: Spec
14spec :: Spec
13spec = describe "Servant.Foreign" $ do
15spec = describe "Servant.Foreign" $ do
14 camelCaseSpec
16 camelCaseSpec
@@ -22,6 +24,10 @@ camelCaseSpec = describe "camelCase" $ do
22 camelCase (FunctionName ["get", "hyphen-ated", "counter"])
24 camelCase (FunctionName ["get", "hyphen-ated", "counter"])
23 `shouldBe` "getHyphen-atedCounter"
25 `shouldBe` "getHyphen-atedCounter"
24
26
27+----------------------------------------------------------------------
28+
29+-- This declaration simply checks that all instances are in place.
30+_ = listFromAPI (Proxy :: Proxy LangX) (Proxy :: Proxy String) comprehensiveAPIWithoutRaw
25
31
26----------------------------------------------------------------------
32----------------------------------------------------------------------
27
33
@@ -30,6 +36,9 @@ data LangX
30instance HasForeignType LangX String NoContent where
36instance HasForeignType LangX String NoContent where
31 typeFor _ _ _ = "voidX"
37 typeFor _ _ _ = "voidX"
32
38
39+instance HasForeignType LangX String (Headers ctyps NoContent) where
40+ typeFor _ _ _ = "voidX"
41+
33instance HasForeignType LangX String Int where
42instance HasForeignType LangX String Int where
34 typeFor _ _ _ = "intX"
43 typeFor _ _ _ = "intX"
35
44