Skip to content

Commit

Permalink
flatten result after tryJust to a single 'Either'
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Jan 14, 2020
1 parent 25fa318 commit 9d61437
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/core/src/Cardano/DB/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import Control.Concurrent.MVar
import Control.Exception
( Exception, bracket_, tryJust )
import Control.Monad
( mapM_ )
( join, mapM_ )
import Control.Monad.Catch
( Handler (..), MonadCatch (..), handleIf, handleJust )
import Control.Monad.Logger
Expand Down Expand Up @@ -191,6 +191,8 @@ startSqliteBackend migrateAll trace fp = do
migrations <- runQuery (runMigrationQuiet migrateAll)
& tryJust (matchMigrationError @PersistException)
& tryJust (matchMigrationError @SqliteException)
& fmap join
:: IO (Either MigrationError [Text])
traceWith trace $ MsgMigrations (fmap length migrations)
let ctx = SqliteContext backend runQuery fp trace
case migrations of
Expand Down
2 changes: 0 additions & 2 deletions lib/core/test/unit/Cardano/Pool/DB/SqliteSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ test_migrationFromv20191216 =
withDBLayer tr (Just path) $ \_ -> pure ()

let databaseConnMsg = filter isMsgConnStr logs

let databaseResetMsg = filter (== MsgDatabaseReset) logs

let migrationErrMsg = filter isMsgMigrationError logs

length databaseConnMsg `shouldBe` 3
Expand Down

0 comments on commit 9d61437

Please sign in to comment.