migrant-sqlite-simple 0.1.0.3 → 0.1.1.1
raw patch · 2 files changed
+68/−6 lines, 2 filesdep ~migrant-coredep ~tastydep ~tasty-quickcheckPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: migrant-core, tasty, tasty-quickcheck
API changes (from Hackage documentation)
Files
migrant-sqlite-simple.cabal view
@@ -3,7 +3,7 @@ -- For further documentation, see http://haskell.org/cabal/users-guide/ name: migrant-sqlite-simple-version: 0.1.0.3+version: 0.1.1.1 synopsis: Semi-automatic database schema migrations -- description: homepage: https://github.com/tdammers/migrant@@ -20,7 +20,7 @@ exposed-modules: Database.Migrant.Driver.Sqlite -- other-extensions: build-depends: base >=4.12.0.0 && <5- , migrant-core+ , migrant-core >= 0.1.1.1 && <0.1.2 , sqlite-simple >=0.4.18.0 && <0.5 , text >=1.2 && <3 hs-source-dirs: src@@ -33,12 +33,12 @@ main-is: Spec.hs other-modules: Database.Migrant.Driver.Sqlite_Tests build-depends: base >=4.12.0.0 && <5- , migrant-core , migrant-sqlite-simple+ , migrant-core >= 0.1.1.1 && <0.1.2 , HUnit >=1.6.1.0 && <1.7 , QuickCheck >=2.14.2 && <2.15 , sqlite-simple >=0.4.18.0 && <0.5- , tasty >=1.4 && <1.5+ , tasty >=1.4 && <1.6 , tasty-hunit >=0.10.0.2 && <0.11- , tasty-quickcheck >=0.10.1.1 && <0.11+ , tasty-quickcheck >=0.10.1.1 && <0.12 , text >=1.2 && <3
test/Database/Migrant/Driver/Sqlite_Tests.hs view
@@ -18,6 +18,8 @@ [ testCase "Setup/init" testSqliteSetup , testCase "Up" testSqliteUp , testCase "Down" testSqliteDown+ , testCase "Full rollback" testSqliteFullRollback+ , testCase "Partial rollack" testSqlitePartialRollback ] testSqliteSetup :: Assertion@@ -59,10 +61,70 @@ migrate ["foo"] up down conn migrate [] up down conn - actual <- Sqlite.query_ conn "SELECT name FROM _migrations ORDER BY id"+ actual <- Sqlite.query_ conn "SELECT name FROM _migrations ORDER BY id DESC" let expected = [] :: [Sqlite.Only Text] assertEqual "Down migration logged" expected actual actual <- Sqlite.query_ conn "SELECT COUNT(1) FROM sqlite_master WHERE type = 'table' AND name = 'foo'" let expected = [Sqlite.Only (0 :: Int)] assertEqual "Down migration happened" expected actual++testSqliteFullRollback :: Assertion+testSqliteFullRollback = do+ let up "one" conn = do+ Sqlite.execute_ conn "CREATE TABLE foo (id INTEGER PRIMARY KEY)"+ up "two" conn = do+ Sqlite.execute_ conn "INSERT INTO foo (id) VALUES (1)"+ up name _ = error ("Invalid name " <> show name)+ down "one" conn = do+ Sqlite.execute_ conn "DROP TABLE foo"+ down "two" conn =+ Sqlite.execute_ conn "DELETE FROM foo WHERE 1" + down name _ = error ("Invalid name " <> show name)+ conn <- Sqlite.open ":memory:"+ migrate ["one", "two"] up down conn+ migrate [] up down conn++ actual <- Sqlite.query_ conn "SELECT name FROM _migrations ORDER BY id DESC"+ let expected = [] :: [Sqlite.Only Text]+ assertEqual "Down migration logged" expected actual++ actual <- Sqlite.query_ conn "SELECT COUNT(1) FROM sqlite_master WHERE type = 'table' AND name = 'foo'"+ let expected = [Sqlite.Only (0 :: Int)]+ assertEqual "Down migration happened" expected actual++testSqlitePartialRollback :: Assertion+testSqlitePartialRollback = do+ let up "one" conn = do+ putStrLn "up one"+ Sqlite.execute_ conn "CREATE TABLE foo (id INTEGER PRIMARY KEY)"+ up "two" conn = do+ putStrLn "up two"+ Sqlite.execute_ conn "CREATE TABLE boo (id INTEGER PRIMARY KEY)"+ up "three" conn = do+ putStrLn "up three"+ Sqlite.execute_ conn "INSERT INTO boo (id) VALUES (1)"+ up name _ = error ("Invalid name " <> show name)+ down "one" conn = do+ putStrLn "down one"+ Sqlite.execute_ conn "DROP TABLE foo"+ down "two" conn = do+ putStrLn "down two"+ Sqlite.execute_ conn "DROP TABLE boo"+ down "three" conn = do+ putStrLn "down three"+ Sqlite.execute_ conn "DELETE FROM boo WHERE 1" + down name _ = error ("Invalid name " <> show name)+ conn <- Sqlite.open ":memory:"+ migrate ["one", "two", "three"] up down conn+ migrate ["one"] up down conn++ actual <- Sqlite.query_ conn "SELECT name FROM _migrations ORDER BY id DESC"+ let expected = [Sqlite.Only "one"] :: [Sqlite.Only Text]+ assertEqual "Down migration logged" expected actual++ actual <- Sqlite.query_ conn "SELECT COUNT(1) FROM sqlite_master WHERE type = 'table' AND name = 'boo'"+ let expected = [Sqlite.Only (0 :: Int)]+ assertEqual "Down migration happened" expected actual++