-- | Coverage for 'Pqi.loCreat': creating a new large object with a
-- server-assigned OID.
--
-- The assigned OID differs between the candidate's and the reference's runs,
-- so only its presence is compared.
module Pqi.Conformance.Operation.LoCreat
  ( spec,
  )
where

import qualified Pqi
import Pqi.Conformance.Harness
import Pqi.Conformance.Prelude
import Pqi.Conformance.Scenario (inTransaction)
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
"loCreat" do
    String
-> (ByteString -> IO ()) -> SpecWith (Arg (ByteString -> IO ()))
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"creates a large object" \ByteString
conninfo ->
      Adapter -> ByteString -> (Connection -> IO Bool) -> IO ()
forall a.
(Eq a, Show a, HasCallStack) =>
Adapter -> ByteString -> (Connection -> IO a) -> IO ()
differential Adapter
adapter ByteString
conninfo \Connection
connection ->
        Connection -> IO Bool -> IO Bool
forall a. Connection -> IO a -> IO a
inTransaction Connection
connection do
          oid <- Connection -> IO (Maybe Word32)
Pqi.loCreat Connection
connection
          traverse_ (Pqi.loUnlink connection) oid
          pure (isJust oid)