core: don't create and drop postgres db around unit tests (#6350)

This commit is contained in:
spaced4ndy
2025-10-10 07:40:09 +00:00
committed by GitHub
parent 37c8aca3b3
commit ad12f840f1

View File

@@ -26,7 +26,7 @@ import ViewTests
import Control.Exception (bracket_)
import PostgresSchemaDump
import Simplex.Chat.Store.Postgres.Migrations (migrations)
import Simplex.Messaging.Agent.Store.Postgres.Util (createDBAndUserIfNotExists, dropAllSchemasExceptSystem, dropDatabaseAndUser)
import Simplex.Messaging.Agent.Store.Postgres.Util (createDBAndUserIfNotExists, dropDatabaseAndUser)
import System.Directory (createDirectoryIfMissing, removePathForcibly)
#else
import APIDocs
@@ -44,13 +44,9 @@ main = do
agentQueryStats <- TM.emptyIO
#endif
withGlobalLogging logCfg . hspec
#if defined(dbPostgres)
. before_ (dropDatabaseAndUser testDBConnectInfo >> createDBAndUserIfNotExists testDBConnectInfo)
. after_ (dropDatabaseAndUser testDBConnectInfo)
#endif
$ do
#if defined(dbPostgres)
around_ (bracket_ (createDirectoryIfMissing False "tests/tmp") (removePathForcibly "tests/tmp")) $
createdDropDb . around_ (bracket_ (createDirectoryIfMissing False "tests/tmp") (removePathForcibly "tests/tmp")) $
describe "Postgres schema dump" $
postgresSchemaDumpTest
migrations
@@ -70,7 +66,7 @@ main = do
describe "Operators" operatorTests
describe "Random servers" randomServersTests
#if defined(dbPostgres)
around testBracket
createdDropDb . around testBracket
#else
around (testBracket chatQueryStats agentQueryStats)
#endif
@@ -87,6 +83,9 @@ main = do
#endif
where
#if defined(dbPostgres)
createdDropDb =
before_ (dropDatabaseAndUser testDBConnectInfo >> createDBAndUserIfNotExists testDBConnectInfo)
. after_ (dropDatabaseAndUser testDBConnectInfo)
testBracket test = withSmpServer $ tmpBracket $ \tmpPath -> test TestParams {tmpPath, printOutput = False}
#else
testBracket chatQueryStats agentQueryStats test =