module Pqi.Conformance.Operation.ResultStatus
( spec,
)
where
import qualified Pqi
import Pqi.Conformance.Harness
import Pqi.Conformance.Prelude
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
"resultStatus" do
String
-> (ByteString -> IO ()) -> SpecWith (Arg (ByteString -> IO ()))
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"reports the status for each kind of result" \ByteString
conninfo ->
Adapter
-> ByteString
-> (Connection
-> IO
(Maybe ExecStatus, Maybe ExecStatus, Maybe ExecStatus,
Maybe ExecStatus))
-> IO ()
forall a.
(Eq a, Show a, HasCallStack) =>
Adapter -> ByteString -> (Connection -> IO a) -> IO ()
differential Adapter
adapter ByteString
conninfo \Connection
connection -> do
let statusOf :: ByteString -> IO (Maybe ExecStatus)
statusOf ByteString
sql = Connection -> ByteString -> IO (Maybe Result)
Pqi.exec Connection
connection ByteString
sql IO (Maybe Result)
-> (Maybe Result -> IO (Maybe ExecStatus)) -> IO (Maybe ExecStatus)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Result -> IO ExecStatus) -> Maybe Result -> IO (Maybe ExecStatus)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse Result -> IO ExecStatus
Pqi.resultStatus
tuples <- ByteString -> IO (Maybe ExecStatus)
statusOf ByteString
"select 1"
command <- statusOf "create temporary table conformance_status (id int4)"
empty <- statusOf ""
failed <- statusOf "selct 1"
pure (tuples, command, empty, failed)