packages feed

hdbi-tests 1.1.0 → 1.1.1

raw patch · 2 files changed

+34/−4 lines, 2 filesdep +stmdep ~base

Dependencies added: stm

Dependency ranges changed: base

Files

Database/HDBI/Tests.hs view
@@ -11,13 +11,18 @@        , allTests        ) where + import Control.Applicative+import Control.Concurrent+import Control.Concurrent.STM.TVar+import Control.Monad+import Control.Monad.STM import Data.AEq import Data.Decimal+import Data.Fixed import Data.Int-import Data.Monoid import Data.List (intercalate, sort)-import Data.Fixed+import Data.Monoid import Data.Time import Data.UUID import Data.Word@@ -280,6 +285,28 @@     getColumnNames s >>= (@?= ["val1", "val2", "val3"])     getColumnsCount s >>= (@?= 3) +concurrentInserts :: (Connection con) => con -> Assertion+concurrentInserts c = do+  let threads = 1000+  v <- newTVarIO threads+  withTransaction c $ do+    runRaw c "delete from integers"+    replicateM_ threads $ forkIO $ onethread v+    atomically $ do               -- wait until all threads done+      x <- readTVar v+      when (x > 0) retry+  a <- withStatement c "select sum(val1) from integers" $ \st -> do+    executeRaw st+    [[res]] <- fetchAllRows st+    return $ fromSql res+  a @?= threads++  where+    onethread var = do+      run c "insert into integers (val1) values (?)" [toSql (1 :: Int)]+      atomically $ modifyTVar var (\a -> a - 1)+      return ()+ testCases :: (Connection con) => con -> Test testCases c = testGroup "Fixed tests"            [ testCase "Statement status" $ stmtStatus c@@ -287,4 +314,5 @@            , testCase "Connection status is good" $ connStatusGood c            , testCase "Connection clone works" $ connClone c            , testCase "Check right column names" $ checkColumnNames c+           , testCase "Concurent inserts dont fail" $ concurrentInserts c            ]
hdbi-tests.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                hdbi-tests-version:             1.1.0+version:             1.1.1 synopsis:            test suite for testing HDBI description:         The set of database-independent tests for   testing the common interface implementation by drivers.@@ -24,7 +24,8 @@ library   exposed-modules:     Database.HDBI.Tests   ghc-options: -Wall -fno-warn-orphans-  build-depends:       base ==4.5.*+  ghc-prof-options: -auto-all+  build-depends:       base < 5                      , Decimal >= 0.2.1                      , HUnit                      , QuickCheck@@ -34,6 +35,7 @@                      , ieee754                      , quickcheck-assertions                      , quickcheck-instances+                     , stm                      , test-framework <= 0.7                      , test-framework-hunit                      , test-framework-quickcheck2