test: tidy inlining plan test

This commit is contained in:
steve-chavez
2023-03-29 05:33:38 -05:00
committed by Steve Chavez
parent caaa9a3944
commit 46fd856fc6
+4 -8
View File
@@ -347,27 +347,23 @@ spec actualPgVersion = do
liftIO $ planCost r `shouldSatisfy` (< 5.85) liftIO $ planCost r `shouldSatisfy` (< 5.85)
context "function inlining" $ do context "function inlining" $ do
it "should inline a zero argument function" $ do it "should inline a zero argument function(the function won't appear in the plan tree)" $ do
r <- request methodGet "/rpc/getallusers?id=eq.1" r <- request methodGet "/rpc/getallusers?id=eq.1"
[(hAccept, "application/vnd.pgrst.plan")] "" [(hAccept, "application/vnd.pgrst.plan")] ""
let resBody = simpleBody r let resBody = simpleBody r
liftIO $ do liftIO $ do
resBody `shouldSatisfy` ( resBody `shouldSatisfy` (\t -> not $ T.isInfixOf "getallusers" (decodeUtf8 $ BS.toStrict t))
if actualPgVersion >= pgVersion120
then (\t -> T.isInfixOf "Index Scan using users_pkey on users" (decodeUtf8 $ BS.toStrict t))
else (\t -> T.isInfixOf "Seq Scan on users" (decodeUtf8 $ BS.toStrict t)))
it "should inline a function with arguments" $ do it "should inline a function with arguments(the function won't appear in the plan tree)" $ do
r <- request methodGet "/rpc/getitemrange?min=10&max=15" r <- request methodGet "/rpc/getitemrange?min=10&max=15"
[(hAccept, "application/vnd.pgrst.plan")] "" [(hAccept, "application/vnd.pgrst.plan")] ""
let resBody = simpleBody r let resBody = simpleBody r
liftIO $ do liftIO $ do
-- a Seq Scan ensures the function is inlined as the plan uses the underlying table resBody `shouldSatisfy` (\t -> not $ T.isInfixOf "getitemrange" (decodeUtf8 $ BS.toStrict t))
resBody `shouldSatisfy` (\t -> T.isInfixOf "Seq Scan on items" (decodeUtf8 $ BS.toStrict t))
disabledSpec :: SpecWith ((), Application) disabledSpec :: SpecWith ((), Application)
disabledSpec = disabledSpec =