Skip to content

Commit efcef2d

Browse files
authored
xftp-web: add postgres schema cleanup for integration tests (#1741)
Stale postgres schema leaked pending XFTP operations between cross-language tests, causing N-1 of N tests to fail.
1 parent 963d7b2 commit efcef2d

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

tests/Test.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import XFTPWebTests (xftpWebTests)
4040

4141
#if defined(dbPostgres)
4242
import Fixtures
43+
import Simplex.Messaging.Agent.Store.Postgres.Util (dropAllSchemasExceptSystem)
4344
#else
4445
import AgentTests.SchemaDump (schemaDumpTest)
4546
#endif
@@ -151,7 +152,11 @@ main = do
151152
describe "XFTP file description" fileDescriptionTests
152153
describe "XFTP CLI" xftpCLITests
153154
describe "XFTP agent" xftpAgentTests
154-
describe "XFTP Web Client" xftpWebTests
155+
#if defined(dbPostgres)
156+
describe "XFTP Web Client" $ xftpWebTests (dropAllSchemasExceptSystem testDBConnectInfo)
157+
#else
158+
describe "XFTP Web Client" $ xftpWebTests (pure ())
159+
#endif
155160
describe "XRCP" remoteControlTests
156161
describe "Web" webTests
157162
describe "Server CLIs" cliTests

tests/XFTPWebTests.hs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import AgentTests.FunctionalAPITests (rfGet, runRight, runRight_, sfGet, withAge
5050
import Simplex.Messaging.Agent (AgentClient, xftpReceiveFile, xftpSendFile, xftpStartWorkers)
5151
import Simplex.Messaging.Agent.Protocol (AEvent (..))
5252
import SMPAgentClient (agentCfg, initAgentServers, testDB)
53-
import XFTPCLI (recipientFiles, senderFiles)
53+
import XFTPCLI (recipientFiles, senderFiles, testBracket)
5454
import qualified Simplex.Messaging.Crypto.File as CF
5555

5656
xftpWebDir :: FilePath
@@ -167,8 +167,8 @@ impAddr = "import * as Addr from './dist/protocol/address.js';"
167167
jsOut :: String -> String
168168
jsOut expr = "process.stdout.write(Buffer.from(" <> expr <> "));"
169169

170-
xftpWebTests :: Spec
171-
xftpWebTests = do
170+
xftpWebTests :: IO () -> Spec
171+
xftpWebTests dbCleanup = do
172172
distExists <- runIO $ doesDirectoryExist (xftpWebDir <> "/dist")
173173
if distExists
174174
then do
@@ -187,7 +187,7 @@ xftpWebTests = do
187187
tsClientTests
188188
tsDownloadTests
189189
tsAddressTests
190-
tsIntegrationTests
190+
tsIntegrationTests dbCleanup
191191
else
192192
it "skipped (run 'cd xftp-web && npm install && npm run build' first)" $
193193
pendingWith "TS project not compiled"
@@ -2829,8 +2829,9 @@ tsAddressTests = describe "protocol/address" $ do
28292829

28302830
-- ── integration ───────────────────────────────────────────────────
28312831

2832-
tsIntegrationTests :: Spec
2833-
tsIntegrationTests = describe "integration" $ do
2832+
tsIntegrationTests :: IO () -> Spec
2833+
tsIntegrationTests dbCleanup = describe "integration" $
2834+
around_ testBracket . after_ dbCleanup $ do
28342835
it "web handshake with Ed25519 identity verification" $
28352836
webHandshakeTest testXFTPServerConfigEd25519SNI "tests/fixtures/ed25519/ca.crt"
28362837
it "web handshake with Ed448 identity verification" $

0 commit comments

Comments
 (0)