Skip to content

Commit

Permalink
better assertions on logs message for db migration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Dec 18, 2019
1 parent c75f3a3 commit b4f8444
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions lib/core/test/unit/Cardano/Pool/DB/SqliteSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import System.FilePath
import System.IO.Temp
( withSystemTempDirectory )
import Test.Hspec
( Spec, describe, it, shouldSatisfy )
( Spec, describe, it, shouldBe )
import Test.Utils.Paths
( getTestData )
import Test.Utils.Trace
Expand Down Expand Up @@ -66,10 +66,22 @@ test_migrationFromv20191216 =
(logs, _) <- captureLogging $ \tr -> do
withDBLayer cfg tr (Just path) $ \_ -> pure ()
withDBLayer cfg tr (Just path) $ \_ -> pure ()
logs `shouldSatisfy`
any (T.isInfixOf "Non backward compatible database found")
logs `shouldSatisfy`
(not . any (T.isInfixOf "PersistError"))

let databaseConnMsg = filter
(T.isInfixOf "Using connection string")
logs

let databaseResetMsg = filter
(T.isInfixOf "Non backward compatible database found")
logs

let migrationErrMsg = filter
(T.isInfixOf "PersistError")
logs

length databaseConnMsg `shouldBe` 3
length databaseResetMsg `shouldBe` 1
length migrationErrMsg `shouldBe` 0

testingLogConfig :: IO CM.Configuration
testingLogConfig = do
Expand Down

0 comments on commit b4f8444

Please sign in to comment.