Skip to content

Commit 7998053

Browse files
authored
Merge pull request #57 from haskellari/tasty
Use tasty in test-suite
2 parents 0541749 + 1d569ce commit 7998053

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

postgresql-libpq.cabal

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
cabal-version: 2.4
22
name: postgresql-libpq
3-
version: 0.10.0.0
4-
x-revision: 1
3+
version: 0.10.1.0
54
synopsis: low-level binding to libpq
65
description:
76
This is a binding to libpq: the C application
@@ -31,8 +30,8 @@ tested-with:
3130
|| ==9.0.2
3231
|| ==9.2.8
3332
|| ==9.4.8
34-
|| ==9.6.3
35-
|| ==9.8.1
33+
|| ==9.6.5
34+
|| ==9.8.2
3635

3736
extra-source-files: CHANGELOG.md
3837

@@ -115,6 +114,8 @@ test-suite smoke
115114
, base
116115
, bytestring
117116
, postgresql-libpq
117+
, tasty ^>=1.5
118+
, tasty-hunit ^>=0.10.1
118119

119120
source-repository head
120121
type: git

test/Smoke.hs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module Main (main) where
22

33
import Control.Monad (unless)
4+
import Test.Tasty (defaultMain, testGroup)
5+
import Test.Tasty.HUnit (testCaseSteps, assertEqual)
46
import Database.PostgreSQL.LibPQ
57
import Data.Foldable (toList)
68
import System.Environment (getEnvironment)
@@ -11,7 +13,9 @@ import qualified Data.ByteString.Char8 as BS8
1113
main :: IO ()
1214
main = do
1315
libpqVersion >>= print
14-
withConnstring smoke
16+
withConnstring $ \connString -> defaultMain $ testGroup "postgresql-libpq"
17+
[ testCaseSteps "smoke" $ \info -> smoke info connString
18+
]
1519

1620
withConnstring :: (BS8.ByteString -> IO ()) -> IO ()
1721
withConnstring kont = do
@@ -35,21 +39,23 @@ withConnstring kont = do
3539
, "port=5432"
3640
]
3741

38-
smoke :: BS8.ByteString -> IO ()
39-
smoke connstring = do
42+
smoke :: (String -> IO ()) -> BS8.ByteString -> IO ()
43+
smoke info connstring = do
44+
let infoShow x = info (show x)
45+
4046
conn <- connectdb connstring
4147

4248
-- status functions
43-
db conn >>= print
44-
user conn >>= print
45-
host conn >>= print
46-
port conn >>= print
47-
status conn >>= print
48-
transactionStatus conn >>= print
49-
protocolVersion conn >>= print
50-
serverVersion conn >>= print
49+
db conn >>= infoShow
50+
user conn >>= infoShow
51+
host conn >>= infoShow
52+
port conn >>= infoShow
53+
status conn >>= infoShow
54+
transactionStatus conn >>= infoShow
55+
protocolVersion conn >>= infoShow
56+
serverVersion conn >>= infoShow
5157

5258
s <- status conn
53-
unless (s == ConnectionOk) exitFailure
59+
assertEqual "connection not ok" s ConnectionOk
5460

5561
finish conn

0 commit comments

Comments
 (0)