postgresql-migration 0.2.1.2 → 0.2.1.3
raw patch · 3 files changed
+33/−12 lines, 3 filesdep ~bytestringdep ~hspecdep ~time
Dependency ranges changed: bytestring, hspec, time
Files
- Readme.markdown +10/−4
- postgresql-migration.cabal +2/−2
- test/Main.hs +21/−6
Readme.markdown view
@@ -158,11 +158,14 @@ cabal configure --enable-tests && cabal build -j ``` -To execute the tests, you need a running PostgreSQL server with an empty-database called _test_. Tests are executed through cabal as follows:+To execute the tests, you need a running PostgreSQL server. You need to set the correct+environment varaiables for the psql connection. +Tests are executed through cabal as follows:+ ```bash-cabal configure --enable-tests && cabal test+cabal configure --enable-tests +PGHOST=localhost PGDATABASE=test make-cabal test ``` To build with stack use the following command@@ -174,8 +177,11 @@ To run the tests with stack use the following command ```bash-stack test+PGHOST=localhost PGDATABASE=test make stack-test ```++NB note that the **psql** test argument must be set for the test suite to run. This is so that other CI environments like+stackage or nix that wont have a running test psql instance will not fail on these tests # Changes from the original postgresql-simple-migration (version 0.1)
postgresql-migration.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: postgresql-migration-version: 0.2.1.2+version: 0.2.1.3 synopsis: PostgreSQL Schema Migrations homepage: https://github.com/andrevdm/postgresql-migration Bug-reports: https://github.com/andrevdm/postgresql-migration/issues@@ -103,4 +103,4 @@ , base >= 4.9 && < 5.0 , bytestring >= 0.10 && < 0.11 , postgresql-simple >= 0.4 && < 0.7- , hspec >= 2.2 && < 2.8+ , hspec >= 2.2 && < 2.9
test/Main.hs view
@@ -10,6 +10,7 @@ -- The test entry-point for postgresql-migration. {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE LambdaCase #-} module Main ( main@@ -21,14 +22,28 @@ import qualified Database.PostgreSQL.Simple.TransactionPerRunTest as V2TrnRun import qualified Database.PostgreSQL.Simple.TransactionPerStepTest as V2TrnStep import Database.PostgreSQL.Simple.Util (withTransactionRolledBack)+import qualified System.Environment as Env+ import Test.Hspec (hspec) main :: IO () main = do- conRollback <- connectPostgreSQL ""- withTransactionRolledBack conRollback (hspec (V2.migrationSpec conRollback))- withTransactionRolledBack conRollback (hspec (V1.migrationSpec conRollback))- withTransactionRolledBack conRollback (hspec (V2TrnRun.migrationSpec conRollback))+ Env.getArgs >>= \case+ ("psql":as) -> Env.withArgs as $ do+ conRollback <- connectPostgreSQL ""+ withTransactionRolledBack conRollback (hspec (V2.migrationSpec conRollback))+ withTransactionRolledBack conRollback (hspec (V1.migrationSpec conRollback))+ withTransactionRolledBack conRollback (hspec (V2TrnRun.migrationSpec conRollback)) - conPerStep <- connectPostgreSQL ""- hspec (V2TrnStep.migrationSpec conPerStep)+ conPerStep <- connectPostgreSQL ""+ hspec (V2TrnStep.migrationSpec conPerStep)++ _ -> do+ putStrLn "Skipping tests, no 'psql' argument provided"+ putStrLn " To run the tests please use one of the following make commands"+ putStrLn " make cabal-test"+ putStrLn " make stack-test"+ putStrLn " or directly"+ putStrLn " stack test --ta psql"+ putStrLn " cabal run --test-show-details=direct test:tests psql"+