mirror of
https://github.com/nikita-volkov/hasql.git
synced 2024-12-25 11:11:36 +03:00
Factor constants out
This commit is contained in:
parent
463559446d
commit
b49c94ed2a
@ -140,7 +140,8 @@ library testing-utils
|
|||||||
import: base
|
import: base
|
||||||
hs-source-dirs: testing-utils
|
hs-source-dirs: testing-utils
|
||||||
exposed-modules:
|
exposed-modules:
|
||||||
Hasql.TestingUtils.Session
|
Hasql.TestingUtils.Constants
|
||||||
|
Hasql.TestingUtils.TestingDsl
|
||||||
|
|
||||||
build-depends:
|
build-depends:
|
||||||
hasql,
|
hasql,
|
||||||
|
@ -5,7 +5,7 @@ import Hasql.Decoders qualified as Decoders
|
|||||||
import Hasql.Encoders qualified as Encoders
|
import Hasql.Encoders qualified as Encoders
|
||||||
import Hasql.Session qualified as Session
|
import Hasql.Session qualified as Session
|
||||||
import Hasql.Statement qualified as Statement
|
import Hasql.Statement qualified as Statement
|
||||||
import Hasql.TestingUtils.Session qualified as Session
|
import Hasql.TestingUtils.TestingDsl qualified as Session
|
||||||
import Main.Connection qualified as Connection
|
import Main.Connection qualified as Connection
|
||||||
import Main.Prelude hiding (assert)
|
import Main.Prelude hiding (assert)
|
||||||
import Main.Statements qualified as Statements
|
import Main.Statements qualified as Statements
|
||||||
|
13
testing-utils/Hasql/TestingUtils/Constants.hs
Normal file
13
testing-utils/Hasql/TestingUtils/Constants.hs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
module Hasql.TestingUtils.Constants where
|
||||||
|
|
||||||
|
import Hasql.Connection qualified as Connection
|
||||||
|
|
||||||
|
localConnectionSettings :: Connection.Settings
|
||||||
|
localConnectionSettings =
|
||||||
|
Connection.settings host port user password database
|
||||||
|
where
|
||||||
|
host = "localhost"
|
||||||
|
port = 5432
|
||||||
|
user = "postgres"
|
||||||
|
password = "postgres"
|
||||||
|
database = "postgres"
|
@ -1,4 +1,4 @@
|
|||||||
module Hasql.TestingUtils.Session
|
module Hasql.TestingUtils.TestingDsl
|
||||||
( Session.Session,
|
( Session.Session,
|
||||||
SessionError (..),
|
SessionError (..),
|
||||||
Session.QueryError (..),
|
Session.QueryError (..),
|
||||||
@ -11,6 +11,7 @@ where
|
|||||||
import Hasql.Connection qualified as Connection
|
import Hasql.Connection qualified as Connection
|
||||||
import Hasql.Session qualified as Session
|
import Hasql.Session qualified as Session
|
||||||
import Hasql.Statement qualified as Statement
|
import Hasql.Statement qualified as Statement
|
||||||
|
import Hasql.TestingUtils.Constants qualified as Constants
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
data SessionError
|
data SessionError
|
||||||
@ -23,16 +24,7 @@ runSession session =
|
|||||||
runExceptT $ acquire >>= \connection -> use connection <* release connection
|
runExceptT $ acquire >>= \connection -> use connection <* release connection
|
||||||
where
|
where
|
||||||
acquire =
|
acquire =
|
||||||
ExceptT $ fmap (mapLeft ConnectionError) $ Connection.acquire settings
|
ExceptT $ fmap (mapLeft ConnectionError) $ Connection.acquire Constants.localConnectionSettings
|
||||||
where
|
|
||||||
settings =
|
|
||||||
Connection.settings host port user password database
|
|
||||||
where
|
|
||||||
host = "localhost"
|
|
||||||
port = 5432
|
|
||||||
user = "postgres"
|
|
||||||
password = "postgres"
|
|
||||||
database = "postgres"
|
|
||||||
use connection =
|
use connection =
|
||||||
ExceptT
|
ExceptT
|
||||||
$ fmap (mapLeft SessionError)
|
$ fmap (mapLeft SessionError)
|
Loading…
Reference in New Issue
Block a user