sydtest-persistent-postgresql 0.5.3.0 → 0.5.3.1
raw patch · 4 files changed
+38/−2 lines, 4 files
Files
- CHANGELOG.md +11/−0
- src/Test/Syd/Persistent/Postgresql.hs +6/−1
- sydtest-persistent-postgresql.cabal +1/−1
- test/Test/Syd/Persistent/PostgresqlSpec.hs +20/−0
CHANGELOG.md view
@@ -1,5 +1,16 @@ # Changelog +## [0.5.3.1] - 2026-11-29++### Fixed++* A test that runs out of time no longer leaves its database behind. Its+ database was created and dropped while the test could be interrupted, and+ the server goes on to create a database whose creation is interrupted,+ which nothing then dropped. Dropping the template's user at the end of the+ suite then failed, because that user owned the database, and so did the+ suite.+ ## [0.5.3.0] - 2026-11-13 ### Added
src/Test/Syd/Persistent/Postgresql.hs view
@@ -688,7 +688,12 @@ ) () pure ()- in SetupFunc $ bracket createDB deleteDB+ in -- Uninterruptible, because a test that runs out of time is+ -- interrupted, and a database that is created or dropped while it is+ -- interrupted is left behind.+ -- The server goes on to create it, but nothing drops it, and then+ -- dropping its owner fails at the end of the suite.+ SetupFunc $ bracket (uninterruptibleMask_ createDB) (uninterruptibleMask_ . deleteDB) withAdminConn :: Temp.DB -> (PostgreSQL.Connection -> IO a) -> IO a withAdminConn db =
sydtest-persistent-postgresql.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: sydtest-persistent-postgresql-version: 0.5.3.0+version: 0.5.3.1 synopsis: An persistent-postgresql companion library for sydtest category: Testing homepage: https://github.com/NorfairKing/sydtest#readme
test/Test/Syd/Persistent/PostgresqlSpec.hs view
@@ -1,7 +1,12 @@+{-# LANGUAGE NumericUnderscores #-}+{-# LANGUAGE OverloadedStrings #-}+ module Test.Syd.Persistent.PostgresqlSpec (spec) where +import Control.Monad import Database.Persist import Database.Persist.Sql+import System.Timeout (timeout) import Test.Syd import Test.Syd.Persistent.Example import Test.Syd.Persistent.Postgresql@@ -26,3 +31,18 @@ runPostgresqlTest pool $ do mp <- get (toSqlKey 0) liftIO $ mp `shouldBe` (Nothing :: Maybe Person)+ describe "connectionPoolSetupFunc" $+ persistPostgresqlAdminSpec migrateExample $+ -- A test that runs out of time is cancelled with an asynchronous+ -- exception, which can arrive while its database is being created.+ -- A database left behind is owned by the template's user, so dropping+ -- that user at the end of the suite fails.+ itWithOuter "leaves no database behind when it is cancelled while it is being set up" $ \templateDB -> do+ forM_ [0, 500 .. 100_000] $ \delay ->+ timeout delay $ unSetupFunc (connectionPoolSetupFunc templateDB) (\_ -> pure ())+ unSetupFunc (connectionPoolSetupFunc templateDB) $ \pool -> do+ databases <-+ runSqlPool+ (rawSql "SELECT datname FROM pg_database WHERE datname LIKE 'test_db_%'" [])+ pool+ length (databases :: [Single String]) `shouldBe` 1