mirror of
https://github.com/nikita-volkov/hasql.git
synced 2024-12-25 03:01:42 +03:00
Test prepared statements and errors
This commit is contained in:
parent
7954c8d734
commit
6cb86412ca
18
hasql.cabal
18
hasql.cabal
@ -130,24 +130,10 @@ test-suite tasty
|
||||
tasty-hunit == 0.9.*,
|
||||
quickcheck-instances >= 0.3.11 && < 0.4,
|
||||
QuickCheck >= 2.8.1 && < 2.9,
|
||||
-- data:
|
||||
uuid,
|
||||
time,
|
||||
scientific,
|
||||
bytestring,
|
||||
text,
|
||||
vector,
|
||||
hashable,
|
||||
dlist,
|
||||
-- general:
|
||||
data-default-class,
|
||||
profunctors,
|
||||
contravariant,
|
||||
contravariant-extras,
|
||||
either,
|
||||
transformers,
|
||||
base-prelude,
|
||||
base
|
||||
-- base,
|
||||
rebase
|
||||
|
||||
|
||||
benchmark benchmark
|
||||
|
@ -22,6 +22,31 @@ tree =
|
||||
localOption (NumThreads 1) $
|
||||
testGroup "All tests"
|
||||
[
|
||||
testCase "Prepared statements after error" $
|
||||
let
|
||||
io =
|
||||
Connection.with (Session.run session) >>=
|
||||
\x -> assertBool (show x) (either (const False) isRight x)
|
||||
where
|
||||
session =
|
||||
try *> fail *> try
|
||||
where
|
||||
try =
|
||||
Session.query 1 query
|
||||
where
|
||||
query =
|
||||
Query.statement sql encoder decoder True
|
||||
where
|
||||
sql =
|
||||
"select $1 :: int8"
|
||||
encoder =
|
||||
Encoders.value Encoders.int8
|
||||
decoder =
|
||||
Decoders.singleRow $ Decoders.value Decoders.int8
|
||||
fail =
|
||||
catchError (Session.sql "absurd") (const (pure ()))
|
||||
in io
|
||||
,
|
||||
testCase "\"in progress after error\" bugfix" $
|
||||
let
|
||||
sumQuery :: Query.Query (Int64, Int64) Int64
|
||||
|
@ -7,67 +7,8 @@ where
|
||||
|
||||
-- base-prelude
|
||||
-------------------------
|
||||
import BasePrelude as Exports hiding (assert, left, right, isLeft, isRight, error)
|
||||
|
||||
-- transformers
|
||||
-------------------------
|
||||
import Control.Monad.IO.Class as Exports
|
||||
import Control.Monad.Trans.Class as Exports
|
||||
import Control.Monad.Trans.Maybe as Exports hiding (liftListen, liftPass)
|
||||
import Control.Monad.Trans.Reader as Exports hiding (liftCallCC, liftCatch)
|
||||
import Control.Monad.Trans.State.Strict as Exports hiding (liftCallCC, liftCatch, liftListen, liftPass)
|
||||
import Data.Functor.Identity as Exports
|
||||
import Rebase.Prelude as Exports
|
||||
|
||||
-- data-default-class
|
||||
-------------------------
|
||||
import Data.Default.Class as Exports
|
||||
|
||||
-- profunctors
|
||||
-------------------------
|
||||
import Data.Profunctor.Unsafe as Exports
|
||||
|
||||
-- contravariant
|
||||
-------------------------
|
||||
import Data.Functor.Contravariant as Exports
|
||||
import Data.Functor.Contravariant.Divisible as Exports
|
||||
|
||||
-- contravariant-extras
|
||||
-------------------------
|
||||
import Contravariant.Extras as Exports
|
||||
|
||||
-- either
|
||||
-------------------------
|
||||
import Control.Monad.Trans.Either as Exports
|
||||
import Data.Either.Combinators as Exports
|
||||
|
||||
-- hashable
|
||||
-------------------------
|
||||
import Data.Hashable as Exports (Hashable(..))
|
||||
|
||||
-- text
|
||||
-------------------------
|
||||
import Data.Text as Exports (Text)
|
||||
|
||||
-- bytestring
|
||||
-------------------------
|
||||
import Data.ByteString as Exports (ByteString)
|
||||
|
||||
-- scientific
|
||||
-------------------------
|
||||
import Data.Scientific as Exports (Scientific)
|
||||
|
||||
-- uuid
|
||||
-------------------------
|
||||
import Data.UUID as Exports (UUID)
|
||||
|
||||
-- time
|
||||
-------------------------
|
||||
import Data.Time as Exports
|
||||
|
||||
-- vector
|
||||
-------------------------
|
||||
import Data.Vector as Exports (Vector)
|
||||
|
||||
-- dlist
|
||||
-------------------------
|
||||
import Data.DList as Exports (DList)
|
||||
|
Loading…
Reference in New Issue
Block a user