mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-03-30 14:15:55 +00:00
core: don't create and drop postgres db around unit tests (#6350)
This commit is contained in:
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user