-- | Coverage for 'Pqi.loUnlink': removing a large object, including the
-- error path for a non-existent object.
module Pqi.Conformance.Operation.LoUnlink
  ( 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
"loUnlink" do
    String
-> (ByteString -> IO ()) -> SpecWith (Arg (ByteString -> IO ()))
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"removes an existing object and rejects a missing one" \ByteString
conninfo ->
      Adapter
-> ByteString
-> (Connection -> IO (Maybe (Maybe ()), Maybe ()))
-> IO ()
forall a.
(Eq a, Show a, HasCallStack) =>
Adapter -> ByteString -> (Connection -> IO a) -> IO ()
differential Adapter
adapter ByteString
conninfo \Connection
connection ->
        Connection
-> IO (Maybe (Maybe ()), Maybe ())
-> IO (Maybe (Maybe ()), Maybe ())
forall a. Connection -> IO a -> IO a
inTransaction Connection
connection do
          oid <- Connection -> IO (Maybe Word32)
Pqi.loCreat Connection
connection
          removed <- for oid (Pqi.loUnlink connection)
          missing <- Pqi.loUnlink connection 4242424
          pure (removed, missing)