module Pqi.Conformance.Operation.Getvalue
( 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
"getvalue" do
String
-> (ByteString -> IO ()) -> SpecWith (Arg (ByteString -> IO ()))
forall a.
(HasCallStack, Example a) =>
String -> a -> SpecWith (Arg a)
it String
"reads cells, nulls, and degrades out of range" \ByteString
conninfo ->
Adapter
-> ByteString
-> (Connection
-> IO
(Maybe
(Maybe ByteString, Maybe ByteString, Maybe ByteString,
Maybe ByteString)))
-> IO ()
forall a.
(Eq a, Show a, HasCallStack) =>
Adapter -> ByteString -> (Connection -> IO a) -> IO ()
differential Adapter
adapter ByteString
conninfo \Connection
connection -> do
result <- Connection -> ByteString -> IO (Maybe Result)
Pqi.exec Connection
connection ByteString
"select 'hello' :: text, null :: int4"
for result \Result
r -> do
present <- Result -> Int32 -> Int32 -> IO (Maybe ByteString)
Pqi.getvalue Result
r Int32
0 Int32
0
nullCell <- Pqi.getvalue r 0 1
badRow <- Pqi.getvalue r 1 0
badColumn <- Pqi.getvalue r 0 5
pure (present, nullCell, badRow, badColumn)