Skip to content

Commit fd08f45

Browse files
authored
Merge pull request #681 from phadej/router-queryparams-tests
Add test illustrating that query params don't affect router grouping
2 parents 25110fe + 7ac095f commit fd08f45

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

servant-server/test/Servant/Server/RouterSpec.hs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
154156
permuteRef :: Proxy PermuteRef
155157
permuteRef = 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

0 commit comments

Comments
 (0)