module Pqi.Conformance.Operation.SetSingleRowMode
( spec,
)
where
import qualified Pqi
import Pqi.Conformance.Harness
import Pqi.Conformance.Prelude
import Pqi.Conformance.Scenario (drainResults)
import Test.Hspec
spec :: Pqi.Adapter -> SpecWith ByteString
spec :: Adapter -> SpecWith ByteString
spec Adapter
adapter =
String -> SpecWith ByteString -> SpecWith ByteString
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
"setSingleRowMode" do
String
-> (ByteString -> IO ()) -> SpecWith (Arg (ByteString -> IO ()))
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"splits a multi-row result into single-row results" \ByteString
conninfo ->
Adapter
-> ByteString
-> (Connection -> IO (Bool, Bool, [ResultObservation]))
-> IO ()
forall a.
(Eq a, Show a, HasCallStack) =>
Adapter -> ByteString -> (Connection -> IO a) -> IO ()
differential Adapter
adapter ByteString
conninfo \Connection
connection -> do
sent <- Connection -> ByteString -> IO Bool
Pqi.sendQuery Connection
connection ByteString
"select i from generate_series (1, 3) as i"
singleRow <- Pqi.setSingleRowMode connection
results <- drainResults connection
pure (sent, singleRow, results)
String
-> (ByteString -> IO ()) -> SpecWith (Arg (ByteString -> IO ()))
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"handles an empty result" \ByteString
conninfo ->
Adapter
-> ByteString
-> (Connection -> IO (Bool, Bool, [ResultObservation]))
-> IO ()
forall a.
(Eq a, Show a, HasCallStack) =>
Adapter -> ByteString -> (Connection -> IO a) -> IO ()
differential Adapter
adapter ByteString
conninfo \Connection
connection -> do
sent <- Connection -> ByteString -> IO Bool
Pqi.sendQuery Connection
connection ByteString
"select 1 where false"
singleRow <- Pqi.setSingleRowMode connection
results <- drainResults connection
pure (sent, singleRow, results)