Files
simplex-chat/tests/SchemaDump.hs
T
Evgeny Poberezkin c62d99ab97 core: remove connection pool (#738)
* core: remove connection pool

* remove local ref from cabal.project

* update simplexmq

* log test

* fix test
2022-06-16 20:00:51 +01:00

31 lines
864 B
Haskell

{-# LANGUAGE OverloadedStrings #-}
module SchemaDump where
import ChatClient (withTmpFiles)
import Control.Monad (void)
import Simplex.Chat.Store (createStore)
import System.Process (readCreateProcess, shell)
import Test.Hspec
testDB :: FilePath
testDB = "tests/tmp/test_chat.db"
schema :: FilePath
schema = "src/Simplex/Chat/Migrations/chat_schema.sql"
schemaDumpTest :: Spec
schemaDumpTest =
it "verify and overwrite schema dump" testVerifySchemaDump
testVerifySchemaDump :: IO ()
testVerifySchemaDump =
withTmpFiles $ do
void $ createStore testDB False
void $ readCreateProcess (shell $ "touch " <> schema) ""
savedSchema <- readFile schema
savedSchema `seq` pure ()
void $ readCreateProcess (shell $ "sqlite3 " <> testDB <> " .schema > " <> schema) ""
currentSchema <- readFile schema
savedSchema `shouldBe` currentSchema