-- | Coverage for 'Pqi.newNullConnection': the sentinel \"null\" connection
-- is reported as null and bad.
module Pqi.Conformance.Operation.NewNullConnection
  ( 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
"newNullConnection" do
    String
-> (ByteString -> IO ()) -> SpecWith (Arg (ByteString -> IO ()))
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"produces a connection that is null and bad" \ByteString
conninfo ->
      Adapter
-> ByteString
-> (Adapter -> ByteString -> IO (Bool, ConnStatus))
-> IO ()
forall a.
(Eq a, Show a, HasCallStack) =>
Adapter -> ByteString -> (Adapter -> ByteString -> IO a) -> IO ()
differentialConnect Adapter
adapter ByteString
conninfo \Adapter
adapter' ByteString
_ -> do
        connection <- Adapter -> IO Connection
Pqi.newNullConnection Adapter
adapter'
        nullness <- pure (Pqi.isNullConnection connection)
        badness <- Pqi.status connection
        Pqi.finish connection
        pure (nullness, badness)