@@ -13,7 +13,7 @@ import Test.Hspec.Core.Spec (Arg, Example, Result (..),
13 defaultParams, evaluateExample)
13 defaultParams, evaluateExample)
14import Test.QuickCheck.Gen (unGen)
14import Test.QuickCheck.Gen (unGen)
15import Test.QuickCheck.Random (mkQCGen)
15import Test.QuickCheck.Random (mkQCGen)
16−import Network.HTTP.Client (queryString)
16+import Network.HTTP.Client (queryString, path)
18#if MIN_VERSION_servant(0,8,0)
18#if MIN_VERSION_servant(0,8,0)
19import Servant.API.Internal.Test.ComprehensiveAPI (comprehensiveAPIWithoutRaw)
19import Servant.API.Internal.Test.ComprehensiveAPI (comprehensiveAPIWithoutRaw)
@@ -34,6 +34,7 @@ spec = do
34 notLongerThanSpec
34 notLongerThanSpec
35 queryParamsSpec
35 queryParamsSpec
36 queryFlagsSpec
36 queryFlagsSpec
38serversEqualSpec :: Spec
39serversEqualSpec :: Spec
39serversEqualSpec = describe "serversEqual" $ do
40serversEqualSpec = describe "serversEqual" $ do
@@ -52,7 +53,7 @@ serversEqualSpec = describe "serversEqual" $ do
52 evalExample $ serversEqual api2 burl1 burl2 args bodyEquality
53 evalExample $ serversEqual api2 burl1 burl2 args bodyEquality
53 show err `shouldContain` "Body: 1"
54 show err `shouldContain` "Body: 1"
54 show err `shouldContain` "Body: 2"
55 show err `shouldContain` "Body: 2"
55− show err `shouldContain` "Path: failplz/"
56+ show err `shouldContain` "Path: /failplz"
57serverSatisfiesSpec :: Spec
58serverSatisfiesSpec :: Spec
58serverSatisfiesSpec = describe "serverSatisfies" $ do
59serverSatisfiesSpec = describe "serverSatisfies" $ do
@@ -113,6 +114,17 @@ isComprehensiveSpec = describe "HasGenRequest" $ do
113 let _g = genRequest comprehensiveAPIWithoutRaw
114 let _g = genRequest comprehensiveAPIWithoutRaw
114 True `shouldBe` True -- This is a type-level check
115 True `shouldBe` True -- This is a type-level check
118+deepPathSpec = describe "Path components" $ do
120+ it "are separated by slashes, without a trailing slash" $ do
122+ burl = BaseUrl Http "localhost" 80 ""
123+ gen = genRequest deepAPI
124+ req = (unGen gen rng 0) burl
125+ path req `shouldBe` ("/one/two/three")
116queryParamsSpec :: Spec
128queryParamsSpec :: Spec
117queryParamsSpec = describe "QueryParams" $ do
129queryParamsSpec = describe "QueryParams" $ do
@@ -170,6 +182,12 @@ type API2 = "failplz" :> Get '[JSON] Int
170api2 :: Proxy API2
182api2 :: Proxy API2
171api2 = Proxy
183api2 = Proxy
185+type DeepAPI = "one" :> "two" :> "three":> Get '[JSON] ()
187+deepAPI :: Proxy DeepAPI
173server2 :: IO (Server API2)
191server2 :: IO (Server API2)
174server2 = return $ return 1
192server2 = return $ return 1