Logically simplify (i)like test cases

This commit is contained in:
Joe Nelson
2015-02-15 17:34:26 -08:00
parent b88192f95a
commit fa48c86195
+13 -15
View File
@@ -15,11 +15,9 @@ testSet = do
clearTable "items" >> clearTable "no_pk" clearTable "items" >> clearTable "no_pk"
createItems 15 createItems 15
pool <- H.acquirePool pgSettings testPoolOpts pool <- H.acquirePool pgSettings testPoolOpts
void . liftIO $ H.session pool $ H.tx Nothing $ void . liftIO $ H.session pool $ H.tx Nothing $ do
mapM_ (H.unitEx . uncurry insertNoPk) [ H.unitEx $ insertNoPk "xyyx" "u"
("lick", "Fun"), ("trick", "funky") H.unitEx $ insertNoPk "xYYx" "v"
, ("barb", "foo"), ("BARD", "FOOD")
]
where where
insertNoPk :: Text -> Text -> H.Stmt H.Postgres insertNoPk :: Text -> Text -> H.Stmt H.Postgres
@@ -41,18 +39,18 @@ spec = beforeAll testSet . afterAll_ (clearTable "items") . around withApp $ do
} }
it "matches with like" $ do it "matches with like" $ do
get "/no_pk?a=like.*ick&order=a.asc" `shouldRespondWith` [json| get "/no_pk?a=like.*yx" `shouldRespondWith` [json|
[{"a":"lick","b":"Fun"},{"a":"trick","b":"funky"}]|] [{"a":"xyyx","b":"u"}]|]
get "/no_pk?b=like.f*&order=a.asc" `shouldRespondWith` [json| get "/no_pk?a=like.xy*" `shouldRespondWith` [json|
[{"a":"barb","b":"foo"},{"a":"trick","b":"funky"}]|] [{"a":"xyyx","b":"u"}]|]
get "/no_pk?a=like.*AR*&order=a.asc" `shouldRespondWith` [json| get "/no_pk?a=like.*YY*" `shouldRespondWith` [json|
[{"a":"BARD","b":"FOOD"}]|] [{"a":"xYYx","b":"v"}]|]
it "matches with ilike" $ do it "matches with ilike" $ do
get "/no_pk?b=ilike.fun*&order=a.asc" `shouldRespondWith` [json| get "/no_pk?a=ilike.xy*&order=b.asc" `shouldRespondWith` [json|
[{"a":"lick","b":"Fun"},{"a":"trick","b":"funky"}]|] [{"a":"xyyx","b":"u"},{"a":"xYYx","b":"v"}]|]
get "/no_pk?a=ilike.*AR*&order=a.asc" `shouldRespondWith` [json| get "/no_pk?a=ilike.*YY*&order=b.asc" `shouldRespondWith` [json|
[{"a":"BARD","b":"FOOD"},{"a":"barb","b":"foo"}]|] [{"a":"xyyx","b":"u"},{"a":"xYYx","b":"v"}]|]
describe "ordering response" $ do describe "ordering response" $ do
it "by a column asc" $ it "by a column asc" $