mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-04-28 06:15:17 +00:00
c74f4d729b
* create/verify agent schema during tests * add --indent to .schema, enable all tests * remove -threaded from test
30 lines
961 B
Haskell
30 lines
961 B
Haskell
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module AgentTests.SchemaDump where
|
|
|
|
import Control.Monad (void)
|
|
import Simplex.Messaging.Agent.Store.SQLite
|
|
import qualified Simplex.Messaging.Agent.Store.SQLite.Migrations as Migrations
|
|
import System.Process (readCreateProcess, shell)
|
|
import Test.Hspec
|
|
|
|
testDB :: FilePath
|
|
testDB = "tests/tmp/test_agent_schema.db"
|
|
|
|
schema :: FilePath
|
|
schema = "src/Simplex/Messaging/Agent/Store/SQLite/Migrations/agent_schema.sql"
|
|
|
|
schemaDumpTest :: Spec
|
|
schemaDumpTest =
|
|
it "verify and overwrite schema dump" testVerifySchemaDump
|
|
|
|
testVerifySchemaDump :: IO ()
|
|
testVerifySchemaDump = do
|
|
void $ createSQLiteStore testDB 1 Migrations.app False
|
|
void $ readCreateProcess (shell $ "touch " <> schema) ""
|
|
savedSchema <- readFile schema
|
|
savedSchema `seq` pure ()
|
|
void $ readCreateProcess (shell $ "sqlite3 " <> testDB <> " '.schema --indent' > " <> schema) ""
|
|
currentSchema <- readFile schema
|
|
savedSchema `shouldBe` currentSchema
|