on master help sign in
Merge pull request #681 from phadej/router-queryparams-tests

Add test illustrating that query params don't affect router grouping

commitfd08f450964f15baef22fcc8ac284c415f1f9c0c authorAlp Mestanogullari <alpmestan@gmail.com> dateSat 21 Jan 2017, 14:38 (10 years ago) parent25110fe7ac095f
1 file changed+15
servant-server/test/Servant/Server/RouterSpec.hs+15
servant-server/test/Servant/Server/RouterSpec.hs+15
@@ -49,6 +49,8 @@ distributivitySpec =
4949 dynamic `shouldHaveSameStructureAs` dynamicRef
5050 it "properly reorders permuted static paths" $ do
5151 permute `shouldHaveSameStructureAs` permuteRef
52+ it "properly reorders permuted static paths in the presence of QueryParams" $ do
53+ permuteQuery `shouldHaveSameStructureAs` permuteRef
5254 it "properly reorders permuted static paths in the presence of Raw in end" $ do
5355 permuteRawEnd `shouldHaveSameStructureAs` permuteRawEndRef
5456 it "properly reorders permuted static paths in the presence of Raw in beginning" $ do
@@ -154,6 +156,19 @@ permute = Proxy
154156permuteRef :: Proxy PermuteRef
155157permuteRef = Proxy
156158
159+-- Adding a "QueryParam" should not affect structure
160+
161+type PermuteQuery =
162+ QueryParam "1" Int :> "a" :> "b" :> "c" :> End
163+ :<|> QueryParam "2" Int :> "b" :> "a" :> "c" :> End
164+ :<|> QueryParam "3" Int :> "a" :> "c" :> "b" :> End
165+ :<|> QueryParam "4" Int :> "c" :> "a" :> "b" :> End
166+ :<|> QueryParam "5" Int :> "b" :> "c" :> "a" :> End
167+ :<|> QueryParam "6" Int :> "c" :> "b" :> "a" :> End
168+
169+permuteQuery :: Proxy PermuteQuery
170+permuteQuery = Proxy
171+
157172-- Adding a 'Raw' in one of the ends should have minimal
158173-- effect on the grouping.
159174