-- | Coverage for 'Pqi.socket': the connection's socket file descriptor.
--
-- The descriptor number itself is per-connection identity, so only its
-- presence on an open connection is compared.
module Pqi.Conformance.Operation.Socket
  ( 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
"socket" do
    String
-> (ByteString -> IO ()) -> SpecWith (Arg (ByteString -> IO ()))
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"is present on an open connection" \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 ->
        Maybe Fd -> Bool
forall a. Maybe a -> Bool
isJust (Maybe Fd -> Bool) -> IO (Maybe Fd) -> IO Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Connection -> IO (Maybe Fd)
Pqi.socket Connection
connection