Skip to content

Commit

Permalink
Add tests for basic column type conversion errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nurpax committed Aug 11, 2012
1 parent 34fc40d commit d90a8fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 1 addition & 2 deletions devenv.sh
Expand Up @@ -4,6 +4,5 @@
# Run tests # Run tests
function rt () function rt ()
{ {
cabal-dev build cabal-dev build && ./dist/build/test/test
./dist/build/test/test
} }
14 changes: 12 additions & 2 deletions test/Errors.hs
@@ -1,8 +1,11 @@
{-# LANGUAGE ScopedTypeVariables #-}


module Errors ( module Errors (
testErrorsColumns testErrorsColumns
) where ) where


import Prelude hiding (catch)
import Control.Exception
import Common import Common


testErrorsColumns :: TestEnv -> Test testErrorsColumns :: TestEnv -> Test
Expand All @@ -13,6 +16,13 @@ testErrorsColumns TestEnv{..} = TestCase $ do
assertEqual "row count" 1 (length rows) assertEqual "row count" 1 (length rows)
assertEqual "string" (Only "test string") (head rows) assertEqual "string" (Only "test string") (head rows)
-- Mismatched number of output columns (selects two, dest type has 1 field) -- Mismatched number of output columns (selects two, dest type has 1 field)
_rows <- query_ conn "SELECT id,t FROM cols" :: IO [Only Int] convFailedTriggered <-
catch ((query_ conn "SELECT id,t FROM cols" :: IO [Only Int]) >> return False)
(\(_ :: ResultError) -> return True)
assertBool "exception" convFailedTriggered
-- Same as above but the other way round (select 1, dst has two)
convFailed <-
catch ((query_ conn "SELECT id FROM cols" :: IO [(Int, String)]) >> return False)
(\(_ :: ResultError) -> return True)
assertBool "exception" convFailed
return () return ()

0 comments on commit d90a8fb

Please sign in to comment.