-- | Coverage for 'Pqi.sendFlushRequest': asking the server to flush its
-- output buffer so pipelined results arrive without a 'Pqi.pipelineSync'.
module Pqi.Conformance.Operation.SendFlushRequest
  ( spec,
  )
where

import qualified Pqi
import qualified Pqi as Lq
import Pqi.Conformance.Harness
import Pqi.Conformance.Prelude
import Pqi.Conformance.Scenario (takeCommandResults, takeResult)
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
"sendFlushRequest" do
    String
-> (ByteString -> IO ()) -> SpecWith (Arg (ByteString -> IO ()))
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"delivers results without a sync" \ByteString
conninfo ->
      Adapter
-> ByteString
-> (Connection
    -> IO
         (Bool, Bool, Bool,
          (Maybe ResultObservation, Maybe ResultObservation), Bool,
          Maybe ResultObservation, Bool))
-> IO ()
forall a.
(Eq a, Show a, HasCallStack) =>
Adapter -> ByteString -> (Connection -> IO a) -> IO ()
differential Adapter
adapter ByteString
conninfo \Connection
connection -> do
        entered <- Connection -> IO Bool
Lq.enterPipelineMode Connection
connection
        sent <- Lq.sendQueryParams connection "select 42" [] Lq.Text
        flushRequested <- Lq.sendFlushRequest connection
        results <- takeCommandResults connection
        synced <- Lq.pipelineSync connection
        syncResult <- takeResult connection
        exited <- Lq.exitPipelineMode connection
        pure (entered, sent, flushRequested, results, synced, syncResult, exited)