diff --git a/hasql.cabal b/hasql.cabal index 4ea6717..b581325 100644 --- a/hasql.cabal +++ b/hasql.cabal @@ -140,7 +140,8 @@ library testing-utils import: base hs-source-dirs: testing-utils exposed-modules: - Hasql.TestingUtils.Session + Hasql.TestingUtils.Constants + Hasql.TestingUtils.TestingDsl build-depends: hasql, diff --git a/tasty/Main.hs b/tasty/Main.hs index 0dff5c2..1f57ef3 100644 --- a/tasty/Main.hs +++ b/tasty/Main.hs @@ -5,7 +5,7 @@ import Hasql.Decoders qualified as Decoders import Hasql.Encoders qualified as Encoders import Hasql.Session qualified as Session 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.Prelude hiding (assert) import Main.Statements qualified as Statements diff --git a/testing-utils/Hasql/TestingUtils/Constants.hs b/testing-utils/Hasql/TestingUtils/Constants.hs new file mode 100644 index 0000000..be657f7 --- /dev/null +++ b/testing-utils/Hasql/TestingUtils/Constants.hs @@ -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" diff --git a/testing-utils/Hasql/TestingUtils/Session.hs b/testing-utils/Hasql/TestingUtils/TestingDsl.hs similarity index 76% rename from testing-utils/Hasql/TestingUtils/Session.hs rename to testing-utils/Hasql/TestingUtils/TestingDsl.hs index f9fe865..9a82667 100644 --- a/testing-utils/Hasql/TestingUtils/Session.hs +++ b/testing-utils/Hasql/TestingUtils/TestingDsl.hs @@ -1,4 +1,4 @@ -module Hasql.TestingUtils.Session +module Hasql.TestingUtils.TestingDsl ( Session.Session, SessionError (..), Session.QueryError (..), @@ -11,6 +11,7 @@ where import Hasql.Connection qualified as Connection import Hasql.Session qualified as Session import Hasql.Statement qualified as Statement +import Hasql.TestingUtils.Constants qualified as Constants import Prelude data SessionError @@ -23,16 +24,7 @@ runSession session = runExceptT $ acquire >>= \connection -> use connection <* release connection where acquire = - ExceptT $ fmap (mapLeft ConnectionError) $ Connection.acquire settings - where - settings = - Connection.settings host port user password database - where - host = "localhost" - port = 5432 - user = "postgres" - password = "postgres" - database = "postgres" + ExceptT $ fmap (mapLeft ConnectionError) $ Connection.acquire Constants.localConnectionSettings use connection = ExceptT $ fmap (mapLeft SessionError)