From c618ccf89b43cc326376bb87e1cd5cca06bfa1cc Mon Sep 17 00:00:00 2001 From: VyacheslavHashov Date: Wed, 1 Feb 2017 07:29:57 +0300 Subject: [PATCH] Test for SimpleQuery and ExtendedQuery in single connection --- tests/Driver.hs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/Driver.hs b/tests/Driver.hs index d0fa152..341a81a 100644 --- a/tests/Driver.hs +++ b/tests/Driver.hs @@ -29,6 +29,7 @@ testDriver = testGroup "Driver" , testCase "Describe statement with no data" testDescribeStatementNoData , testCase "Describe empty statement" testDescribeStatementEmpty , testCase "SimpleQuery" testSimpleQuery + , testCase "SimpleAndExtendedQuery" testSimpleAndExtendedQuery ] makeQuery1 :: B.ByteString -> Query @@ -178,3 +179,22 @@ testSimpleQuery = withConnection $ \c -> do <> "DROP TABLE a;" assertBool "Should be Right" $ isRight r +-- | Simple and extended queries in a sinle connection. +testSimpleAndExtendedQuery :: IO () +testSimpleAndExtendedQuery = withConnection $ \c -> do + let a = "7" + b = "2" + d = "5" + sendBatchAndSync c [ makeQuery1 a , makeQuery1 b] + readReadyForQuery c + checkRightResult c 2 + + rs <- sendSimpleQuery c "SELECT * FROM generate_series(1, 10)" + assertBool "Should be Right" $ isRight rs + + sendBatchAndSync c [makeQuery1 d] + fr <- readReadyForQuery c + assertBool "Should be Right" $ isRight fr + r <- fromMessage . fromRight <$> readNextData c + r @=? d +