simple unit tests for existing functionality

This commit is contained in:
Adam C. Baker
2014-10-08 15:20:26 -07:00
parent e302bb1d19
commit 5063dfe894
+23
View File
@@ -0,0 +1,23 @@
module Unit.PgStructureSpec where
import Test.Hspec
import PgStructure (Table(..), tables, Column(..), columns)
import Database.HDBC (quickQuery)
import SpecHelper(dbWithSchema)
spec :: Spec
spec = around dbWithSchema $ beforeWith setRole $ do
describe "tables" $
it "shows all the tables" $ \conn -> do
ts <- tables "1" conn
map tableName ts `shouldBe` ["auto_incrementing_pk","compound_pk",
"has_fk","items","menagerie","no_pk", "simple_pk"]
describe "columns" $
it "responds with each column for the table" $ \conn -> do
cs <- columns "1" "auto_incrementing_pk" conn
map colName cs `shouldBe` ["id","nullable_string","non_nullable_string",
"inserted_at"]
where setRole = \conn -> quickQuery conn "set role dbapi_test" [] >> return conn