File: TestUtils.hs

package info (click to toggle)
hdbc-postgresql 2.5.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 216 kB
  • sloc: haskell: 1,196; ansic: 62; makefile: 32
file content (25 lines) | stat: -rw-r--r-- 993 bytes parent folder | download | duplicates (27)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module TestUtils(connectDB, sqlTestCase, dbTestCase, printDBInfo) where
import Database.HDBC
import Test.HUnit
import Control.Exception
import SpecificDB(connectDB)

sqlTestCase a = 
    TestCase (handleSqlError a)

dbTestCase a =
    TestCase (do dbh <- connectDB
                 finally (handleSqlError (a dbh))
                         (handleSqlError (disconnect dbh))
             )

printDBInfo = handleSqlError $
    do dbh <- connectDB
       putStrLn "+-------------------------------------------------------------------------"
       putStrLn $ "| Testing HDBC database module: " ++ hdbcDriverName dbh ++
                ", bound to client: " ++ hdbcClientVer dbh
       putStrLn $ "| Proxied driver: " ++ proxiedClientName dbh ++
                ", bound to version: " ++ proxiedClientVer dbh
       putStrLn $ "| Connected to server version: " ++ dbServerVer dbh
       putStrLn "+-------------------------------------------------------------------------\n"
       disconnect dbh