2025-01-10 15:27:29 +04:00
|
|
|
{-# LANGUAGE CPP #-}
|
2025-02-15 16:18:34 +00:00
|
|
|
{-# LANGUAGE DuplicateRecordFields #-}
|
2025-01-24 09:44:53 +00:00
|
|
|
{-# LANGUAGE NamedFieldPuns #-}
|
|
|
|
{-# LANGUAGE TupleSections #-}
|
2025-01-10 15:27:29 +04:00
|
|
|
|
2023-08-01 20:54:51 +01:00
|
|
|
import Bots.BroadcastTests
|
|
|
|
import Bots.DirectoryTests
|
2021-08-05 20:51:48 +01:00
|
|
|
import ChatClient
|
2021-07-07 22:46:38 +01:00
|
|
|
import ChatTests
|
2025-01-24 09:44:53 +00:00
|
|
|
import ChatTests.DBUtils
|
2023-08-01 20:54:51 +01:00
|
|
|
import ChatTests.Utils (xdescribe'')
|
2023-01-31 11:07:48 +00:00
|
|
|
import Control.Logger.Simple
|
|
|
|
import Data.Time.Clock.System
|
2023-10-11 19:11:01 +01:00
|
|
|
import JSONTests
|
2021-05-09 10:53:18 +01:00
|
|
|
import MarkdownTests
|
2023-12-23 17:07:23 +04:00
|
|
|
import MessageBatching
|
2021-07-04 18:42:24 +01:00
|
|
|
import ProtocolTests
|
2024-11-15 07:15:04 +00:00
|
|
|
import OperatorTests
|
2024-08-06 16:13:36 +01:00
|
|
|
import RandomServers
|
2023-10-04 18:36:10 +03:00
|
|
|
import RemoteTests
|
2024-01-17 15:20:13 +00:00
|
|
|
import Test.Hspec hiding (it)
|
2023-01-31 11:07:48 +00:00
|
|
|
import UnliftIO.Temporary (withTempDirectory)
|
2023-10-02 21:56:11 +01:00
|
|
|
import ValidNames
|
2023-11-26 18:16:37 +00:00
|
|
|
import ViewTests
|
2025-01-10 15:27:29 +04:00
|
|
|
#if defined(dbPostgres)
|
|
|
|
import Simplex.Messaging.Agent.Store.Postgres.Util (createDBAndUserIfNotExists, dropAllSchemasExceptSystem, dropDatabaseAndUser)
|
|
|
|
#else
|
2025-01-24 09:44:53 +00:00
|
|
|
import qualified Simplex.Messaging.TMap as TM
|
2025-01-10 15:27:29 +04:00
|
|
|
import MobileTests
|
|
|
|
import SchemaDump
|
2023-02-19 23:51:50 +00:00
|
|
|
import WebRTCTests
|
2025-01-10 15:27:29 +04:00
|
|
|
#endif
|
2021-05-09 10:53:18 +01:00
|
|
|
|
|
|
|
main :: IO ()
|
2022-04-25 16:30:21 +01:00
|
|
|
main = do
|
2023-10-22 11:42:19 +03:00
|
|
|
setLogLevel LogError
|
2025-01-24 09:44:53 +00:00
|
|
|
#if !defined(dbPostgres)
|
2025-01-24 17:49:31 +04:00
|
|
|
chatQueryStats <- TM.emptyIO
|
|
|
|
agentQueryStats <- TM.emptyIO
|
2025-01-24 09:44:53 +00:00
|
|
|
#endif
|
2025-01-10 15:27:29 +04:00
|
|
|
withGlobalLogging logCfg . hspec
|
|
|
|
#if defined(dbPostgres)
|
|
|
|
. beforeAll_ (dropDatabaseAndUser testDBConnectInfo >> createDBAndUserIfNotExists testDBConnectInfo)
|
|
|
|
. afterAll_ (dropDatabaseAndUser testDBConnectInfo)
|
|
|
|
#endif
|
|
|
|
$ do
|
|
|
|
-- TODO [postgres] schema dump for postgres
|
|
|
|
#if !defined(dbPostgres)
|
|
|
|
describe "Schema dump" schemaDumpTest
|
|
|
|
around tmpBracket $ describe "WebRTC encryption" webRTCTests
|
|
|
|
#endif
|
|
|
|
describe "SimpleX chat markdown" markdownTests
|
|
|
|
describe "JSON Tests" jsonTests
|
|
|
|
describe "SimpleX chat view" viewTests
|
|
|
|
describe "SimpleX chat protocol" protocolTests
|
|
|
|
describe "Valid names" validNameTests
|
|
|
|
describe "Message batching" batchingTests
|
|
|
|
describe "Operators" operatorTests
|
|
|
|
describe "Random servers" randomServersTests
|
|
|
|
#if defined(dbPostgres)
|
2025-01-24 09:44:53 +00:00
|
|
|
around testBracket
|
2025-01-10 15:27:29 +04:00
|
|
|
. after_ (dropAllSchemasExceptSystem testDBConnectInfo)
|
2025-01-24 09:44:53 +00:00
|
|
|
#else
|
2025-01-24 17:49:31 +04:00
|
|
|
around (testBracket chatQueryStats agentQueryStats)
|
2025-01-10 15:27:29 +04:00
|
|
|
#endif
|
|
|
|
$ do
|
|
|
|
#if !defined(dbPostgres)
|
|
|
|
describe "Mobile API Tests" mobileTests
|
|
|
|
#endif
|
|
|
|
describe "SimpleX chat client" chatTests
|
|
|
|
xdescribe'' "SimpleX Broadcast bot" broadcastBotTests
|
|
|
|
xdescribe'' "SimpleX Directory service bot" directoryServiceTests
|
|
|
|
describe "Remote session" remoteTests
|
2025-01-24 09:44:53 +00:00
|
|
|
#if !defined(dbPostgres)
|
|
|
|
xdescribe'' "Save query plans" saveQueryPlans
|
|
|
|
#endif
|
2023-01-31 11:07:48 +00:00
|
|
|
where
|
2025-01-24 17:49:31 +04:00
|
|
|
#if defined(dbPostgres)
|
2025-02-15 16:18:34 +00:00
|
|
|
testBracket test = withSmpServer $ tmpBracket $ \tmpPath -> test TestParams {tmpPath, printOutput = False}
|
2025-01-24 09:44:53 +00:00
|
|
|
#else
|
2025-01-24 17:49:31 +04:00
|
|
|
testBracket chatQueryStats agentQueryStats test =
|
2025-02-15 16:18:34 +00:00
|
|
|
withSmpServer $ tmpBracket $ \tmpPath -> test TestParams {tmpPath, chatQueryStats, agentQueryStats, printOutput = False}
|
2025-01-24 09:44:53 +00:00
|
|
|
#endif
|
2023-12-21 00:42:40 +00:00
|
|
|
tmpBracket test = do
|
2023-01-31 11:07:48 +00:00
|
|
|
t <- getSystemTime
|
|
|
|
let ts = show (systemSeconds t) <> show (systemNanoseconds t)
|
2023-12-21 00:42:40 +00:00
|
|
|
withTmpFiles $ withTempDirectory "tests/tmp" ts test
|
2022-04-25 16:30:21 +01:00
|
|
|
|
2023-01-31 11:07:48 +00:00
|
|
|
logCfg :: LogConfig
|
|
|
|
logCfg = LogConfig {lc_file = Nothing, lc_stderr = True}
|