Skip to content

Commit e63e0be

Browse files
committed
test: parameterize XFTP server, agent and CLI tests over store backend
- xftpTest/xftpTest2/xftpTest4/xftpTestN now take XFTPTestBracket as first argument, enabling the same test to run against both memory and PostgreSQL backends. - xftpFileTests (server tests), xftpAgentFileTests (agent tests), and xftpCLIFileTests (CLI tests) are SpecWith-parameterized suites that receive the bracket from HSpec's before combinator. - Test.hs runs each parameterized suite twice: once with xftpMemoryBracket, once with xftpPostgresBracket (CPP-guarded). - STM-specific tests (store log restore/replay) stay in memory-only xftpAgentTests. SNI/CORS tests stay in memory-only xftpServerTests.
1 parent 37b3ad0 commit e63e0be

File tree

6 files changed

+498
-161
lines changed

6 files changed

+498
-161
lines changed

tests/CoreTests/XFTPStoreTests.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{-# LANGUAGE DataKinds #-}
22
{-# LANGUAGE NamedFieldPuns #-}
33
{-# LANGUAGE OverloadedStrings #-}
4-
{-# LANGUAGE ScopedTypeVariables #-}
54

65
module CoreTests.XFTPStoreTests (xftpStoreTests, xftpMigrationTests) where
76

@@ -55,9 +54,6 @@ testSenderId = EntityId "sender001_______"
5554
testRecipientId :: EntityId
5655
testRecipientId = EntityId "recipient001____"
5756

58-
testRecipientId2 :: EntityId
59-
testRecipientId2 = EntityId "recipient002____"
60-
6157
testFileInfo :: C.APublicAuthKey -> FileInfo
6258
testFileInfo sndKey =
6359
FileInfo

tests/Test.hs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ import System.Directory (createDirectoryIfMissing, removeDirectoryRecursive)
3232
import System.Environment (setEnv)
3333
import Test.Hspec hiding (fit, it)
3434
import Util
35-
import XFTPAgent
36-
import XFTPCLI
37-
import XFTPClient (xftpMemoryBracket, xftpServerFiles)
35+
import XFTPAgent (xftpAgentTests, xftpAgentFileTests, xftpAgentRestoreTests)
36+
import XFTPCLI (xftpCLITests, xftpCLIFileTests)
37+
import XFTPClient (xftpMemoryBracket, xftpMemoryBracket2, xftpMemoryBracketClear, xftpServerFiles)
3838
import XFTPServerTests (xftpServerTests, xftpFileTests)
3939
import WebTests (webTests)
4040
import XFTPWebTests (xftpWebTests)
@@ -54,7 +54,7 @@ import PostgresSchemaDump (postgresSchemaDumpTest)
5454
import SMPClient (testServerDBConnectInfo, testStoreDBOpts)
5555
import Simplex.Messaging.Notifications.Server.Store.Migrations (ntfServerMigrations)
5656
import Simplex.Messaging.Server.QueueStore.Postgres.Migrations (serverMigrations)
57-
import XFTPClient (testXFTPDBConnectInfo, xftpPostgresBracket)
57+
import XFTPClient (testXFTPDBConnectInfo, xftpPostgresBracket, xftpPostgresBracket2, xftpPostgresBracketClear)
5858
#endif
5959

6060
#if defined(dbPostgres) || defined(dbServerPostgres)
@@ -157,14 +157,26 @@ main = do
157157
before (pure xftpMemoryBracket) xftpFileTests
158158
describe "XFTP file description" fileDescriptionTests
159159
describe "XFTP CLI" xftpCLITests
160+
describe "XFTP CLI (memory)" $
161+
before (pure (xftpMemoryBracket, xftpMemoryBracket2)) xftpCLIFileTests
160162
describe "XFTP agent" xftpAgentTests
163+
describe "XFTP agent (memory)" $
164+
before (pure xftpMemoryBracket) xftpAgentFileTests
165+
describe "XFTP agent restore (memory)" $
166+
before (pure xftpMemoryBracketClear) xftpAgentRestoreTests
161167
#if defined(dbServerPostgres)
162168
around_ (postgressBracket testXFTPDBConnectInfo) $ do
163169
describe "XFTP Postgres store operations" xftpStoreTests
164170
describe "XFTP migration round-trip" xftpMigrationTests
165171
before_ (createDirectoryIfMissing False xftpServerFiles) . after_ (removeDirectoryRecursive xftpServerFiles) $
166172
describe "XFTP file delivery (PostgreSQL)" $
167173
before (pure xftpPostgresBracket) xftpFileTests
174+
describe "XFTP agent (PostgreSQL)" $
175+
before (pure xftpPostgresBracket) xftpAgentFileTests
176+
describe "XFTP agent restore (PostgreSQL)" $
177+
before (pure xftpPostgresBracketClear) xftpAgentRestoreTests
178+
describe "XFTP CLI (PostgreSQL)" $
179+
before (pure (xftpPostgresBracket, xftpPostgresBracket2)) xftpCLIFileTests
168180
#endif
169181
#if defined(dbPostgres)
170182
describe "XFTP Web Client" $ xftpWebTests (dropAllSchemasExceptSystem testDBConnectInfo)

0 commit comments

Comments
 (0)