Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add tests for basic column type conversion errors

  • Loading branch information...
commit d90a8fbb420505fa970770132740d13dae6a1f5b 1 parent 34fc40d
@nurpax authored
Showing with 13 additions and 4 deletions.
  1. +1 −2  devenv.sh
  2. +12 −2 test/Errors.hs
View
3  devenv.sh
@@ -4,6 +4,5 @@
# Run tests
function rt ()
{
- cabal-dev build
- ./dist/build/test/test
+ cabal-dev build && ./dist/build/test/test
}
View
14 test/Errors.hs
@@ -1,8 +1,11 @@
+{-# LANGUAGE ScopedTypeVariables #-}
module Errors (
testErrorsColumns
) where
+import Prelude hiding (catch)
+import Control.Exception
import Common
testErrorsColumns :: TestEnv -> Test
@@ -13,6 +16,13 @@ testErrorsColumns TestEnv{..} = TestCase $ do
assertEqual "row count" 1 (length rows)
assertEqual "string" (Only "test string") (head rows)
-- 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 ()
-
Please sign in to comment.
Something went wrong with that request. Please try again.