packages feed

atelier-testing 0.2.0.0 → 0.3.0.0

raw patch · 5 files changed

+58/−33 lines, 5 filesdep −string-conversionsdep ~atelier-coredep ~atelier-dbdep ~hasql-pool

Dependencies removed: string-conversions

Dependency ranges changed: atelier-core, atelier-db, hasql-pool

Files

CHANGELOG.md view
@@ -7,6 +7,15 @@  ## [Unreleased] +## [0.3.0.0] - 2026-08-14++### Changed++- Major version bump for the following dependencies' upper version bounds:+  - `atelier-core`+  - `atelier-db`+  - `hasql-pool`+ ## [0.2.0.0] - 2026-08-13  ### Changed
LICENSE view
@@ -1,6 +1,6 @@ MIT License -Copyright (c) 2025 Christian Georgii+Copyright (c) 2026 Tweag  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
README.md view
@@ -4,11 +4,10 @@  ## Overview -`atelier-testing` spins up a throwaway PostgreSQL instance for integration tests, so suites that exercise [`atelier-db`](https://github.com/tweag/tricorder/tree/main/atelier-db) can run against a real database without external setup.--| Module | Purpose |-|---|---|-| `Atelier.Testing.Database` | Provision and tear down a temporary PostgreSQL database for tests |+`atelier-testing` spins up a throwaway PostgreSQL instance for integration+tests, so suites that exercise+[`atelier-db`](https://github.com/tweag/tricorder/tree/main/atelier-db) can run+against a real database without external setup.  ## Part of atelier @@ -16,6 +15,7 @@ - [`atelier-core`](https://github.com/tweag/tricorder/tree/main/atelier-core) — foundational effects and utilities - [`atelier-db`](https://github.com/tweag/tricorder/tree/main/atelier-db) — relational database effect (Hasql/Rel8) - [`atelier-testing`](https://github.com/tweag/tricorder/tree/main/atelier-testing) — this package+- [`atelier-monitoring`](https://github.com/tweag/tricorder/tree/main/atelier-monitoring) - observability and monitoring effects and utilities  ## License 
atelier-testing.cabal view
@@ -5,14 +5,14 @@ -- see: https://github.com/sol/hpack  name:           atelier-testing-version:        0.2.0.0+version:        0.3.0.0 synopsis:       Database-backed test utilities for atelier description:    Test utilities for database-backed tests using tmp-postgres — part of the atelier toolkit. category:       Testing homepage:       https://github.com/tweag/tricorder#readme bug-reports:    https://github.com/tweag/tricorder/issues-author:         Christian Georgii-maintainer:     christian.georgii@tweag.io+author:         Victor Nascimento Bakke+maintainer:     victor.bakke@tweag.io license:        MIT license-file:   LICENSE build-type:     Simple@@ -57,17 +57,16 @@       TypeFamilies   ghc-options: -Weverything -Wno-unsafe -Wno-missing-safe-haskell-mode -Wno-monomorphism-restriction -Wno-missing-kind-signatures -Wno-missing-local-signatures -Wno-missing-import-lists -Wno-implicit-prelude -Wno-unticked-promoted-constructors -Wno-unused-packages -Wno-all-missed-specialisations -Wno-missed-specialisations -fplugin=Effectful.Plugin -threaded   build-depends:-      atelier-core ==0.3.*-    , atelier-db >=0.1 && <0.3+      atelier-core >=0.3 && <0.5+    , atelier-db >=0.1 && <0.4     , atelier-prelude >=0.1 && <0.3     , base >=4.18 && <4.23     , effectful-core ==2.6.*     , effectful-plugin >=2.0 && <2.2     , hasql >=1.9 && <1.11-    , hasql-pool ==1.3.*+    , hasql-pool >=1.3 && <1.5     , hspec ==2.11.*     , postgres-options ==0.2.*-    , string-conversions ==0.4.*     , text ==2.1.*     , tmp-postgres ==1.35.*     , unix ==2.8.*
src/Atelier/Testing/Database.hs view
@@ -11,10 +11,26 @@     ) where -import Atelier.Effects.DB.Config (DBConfig (..), DBPools (..), PoolConfig (..), acquireDatabasePool, acquireDatabasePools)+import Atelier.Effects.DB.Config+    ( DBConfig (..)+    , DBPools (..)+    , PoolConfig (..)+    , acquireDatabasePool+    , acquireDatabasePools+    ) import Atelier.Exception (trySyncIO)-import Control.Concurrent (MVar, forkIO, modifyMVar, newEmptyMVar, newMVar, putMVar, takeMVar, threadDelay, tryPutMVar, withMVar)-import Data.String.Conversions (cs)+import Control.Concurrent+    ( MVar+    , forkIO+    , modifyMVar+    , newEmptyMVar+    , newMVar+    , putMVar+    , takeMVar+    , threadDelay+    , tryPutMVar+    , withMVar+    ) import Database.PostgreSQL.Simple.Options (Options (..)) import Hasql.Session (Session, statement) import Hasql.Statement (Statement (..))@@ -95,9 +111,9 @@                             }                     adminConfig =                         DBConfig-                            { host = cs socketDir+                            { host = toText socketDir                             , port = portNum-                            , user = cs tmpUser+                            , user = toText tmpUser                             , password = ""                             , databaseName = "postgres"                             , pool = pool@@ -146,16 +162,16 @@     dbName <- generateUniqueDatabaseName     let adminConfig =             DBConfig-                { host = cs server.socketDir+                { host = toText server.socketDir                 , port = server.portNum-                , user = cs server.tmpUser+                , user = toText server.tmpUser                 , password = ""                 , databaseName = "postgres"                 , pool = server.defaultPool                 }         readerConfig =             DBConfig-                { host = cs server.socketDir+                { host = toText server.socketDir                 , port = server.portNum                 , user = cfg.readerUser                 , password = ""@@ -164,7 +180,7 @@                 }         writerConfig =             DBConfig-                { host = cs server.socketDir+                { host = toText server.socketDir                 , port = server.portNum                 , user = cfg.writerUser                 , password = ""@@ -181,7 +197,7 @@     runOrThrow pool         $ statement ()         $ Statement-            (cs $ "CREATE DATABASE " <> dbName <> " TEMPLATE " <> templateName)+            (encodeUtf8 $ "CREATE DATABASE " <> dbName <> " TEMPLATE " <> templateName)             mempty             Decoders.noResult             False@@ -191,7 +207,7 @@ createDatabase pool dbName =     runOrThrow pool         $ statement ()-        $ Statement (cs $ "CREATE DATABASE " <> dbName) mempty Decoders.noResult False+        $ Statement (encodeUtf8 $ "CREATE DATABASE " <> dbName) mempty Decoders.noResult False   -- | Grant TRUNCATE on all tables in the schema to the writer role.@@ -202,7 +218,7 @@     runOrThrow pool         $ statement ()         $ Statement-            (cs $ "GRANT TRUNCATE ON ALL TABLES IN SCHEMA " <> schema <> " TO " <> writerRole)+            (encodeUtf8 $ "GRANT TRUNCATE ON ALL TABLES IN SCHEMA " <> schema <> " TO " <> writerRole)             mempty             Decoders.noResult             False@@ -219,7 +235,7 @@     queryTableNames :: Statement () [Text]     queryTableNames =         Statement-            ( cs+            ( encodeUtf8                 $ "SELECT tablename FROM pg_tables WHERE schemaname = '"                     <> cfg.schemaName                     <> "'"@@ -230,18 +246,19 @@             True      exclusions =-        if null cfg.excludedTables then-            ""-        else-            " AND tablename NOT IN ("-                <> Text.intercalate "," (map (\t -> "'" <> t <> "'") cfg.excludedTables)-                <> ")"+        if null cfg.excludedTables+            then+                ""+            else+                " AND tablename NOT IN ("+                    <> Text.intercalate "," (map (\t -> "'" <> t <> "'") cfg.excludedTables)+                    <> ")"      truncateTables :: Text -> Session ()     truncateTables tableNames =         statement ()             $ Statement-                (cs $ "TRUNCATE TABLE " <> tableNames <> " CASCADE")+                (encodeUtf8 $ "TRUNCATE TABLE " <> tableNames <> " CASCADE")                 mempty                 Decoders.noResult                 False