module Pqi.Conformance.Operation.ResultErrorMessage
( 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
"resultErrorMessage" do
String
-> (ByteString -> IO ()) -> SpecWith (Arg (ByteString -> IO ()))
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"matches the full formatted libpq error string on failure and is empty on success" \ByteString
conninfo ->
Adapter
-> ByteString
-> (Connection
-> IO (Maybe (Maybe ByteString), Maybe (Maybe ByteString)))
-> IO ()
forall a.
(Eq a, Show a, HasCallStack) =>
Adapter -> ByteString -> (Connection -> IO a) -> IO ()
differential Adapter
adapter ByteString
conninfo \Connection
connection -> do
failed <-
Connection -> ByteString -> IO (Maybe Result)
Pqi.exec Connection
connection ByteString
"do $$ begin raise exception 'conformance error'; end $$"
IO (Maybe Result)
-> (Maybe Result -> IO (Maybe (Maybe ByteString)))
-> IO (Maybe (Maybe ByteString))
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 (Maybe ByteString))
-> Maybe Result -> IO (Maybe (Maybe ByteString))
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 (Maybe ByteString)
Pqi.resultErrorMessage
succeeded <-
Pqi.exec connection "select 1"
>>= traverse Pqi.resultErrorMessage
pure (failed, succeeded)