Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rel8.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ library
, comonad
, contravariant
, data-textual
, hasql >= 1.6.1.2 && < 1.9
, hasql >= 1.6.1.2 && < 1.10
, network-ip ^>= 0.3
, iproute ^>= 1.7
, opaleye ^>= 0.10.2.1
Expand Down
21 changes: 18 additions & 3 deletions tests/Main.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# language BangPatterns #-}
{-# language BlockArguments #-}
{-# LANGUAGE CPP #-}
{-# language DeriveAnyClass #-}
{-# language DeriveGeneric #-}
{-# language DerivingVia #-}
Expand Down Expand Up @@ -43,6 +44,7 @@ import Prelude hiding (truncate)

-- bytestring
import qualified Data.ByteString.Lazy
import Data.ByteString ( ByteString )

-- case-insensitive
import Data.CaseInsensitive ( mk )
Expand All @@ -52,7 +54,11 @@ import Data.Containers.ListUtils ( nubOrdOn )
import qualified Data.Map.Strict as Map

-- hasql
import Hasql.Connection ( Connection, acquire, release )
import Hasql.Connection ( Connection, ConnectionError, acquire, release )
#if MIN_VERSION_hasql(1,9,0)
import qualified Hasql.Connection.Setting
import qualified Hasql.Connection.Setting.Connection
#endif
import Hasql.Session ( sql, run )

-- hasql-transaction
Expand Down Expand Up @@ -156,7 +162,7 @@ tests =
startTestDatabase = do
db <- TmpPostgres.start >>= either throwIO return

bracket (either (error . show) return =<< acquire (TmpPostgres.toConnectionString db)) release \conn -> void do
bracket (either (error . show) return =<< acquireFromConnectionString (TmpPostgres.toConnectionString db)) release \conn -> void do
flip run conn do
sql "CREATE EXTENSION citext"
sql "CREATE TABLE test_table ( column1 text not null, column2 bool not null )"
Expand All @@ -170,8 +176,17 @@ tests =


connect :: TmpPostgres.DB -> IO Connection
connect = acquire . TmpPostgres.toConnectionString >=> either (maybe empty (fail . unpack . decodeUtf8)) pure
connect = acquireFromConnectionString . TmpPostgres.toConnectionString >=> either (maybe empty (fail . unpack . decodeUtf8)) pure

acquireFromConnectionString :: ByteString -> IO (Either ConnectionError Connection)
acquireFromConnectionString connectionString =
#if MIN_VERSION_hasql(1,9,0)
acquire
[ Hasql.Connection.Setting.connection . Hasql.Connection.Setting.Connection.string . decodeUtf8 $ connectionString
]
#else
acquire connectionString
#endif

databasePropertyTest
:: TestName
Expand Down