@@ -325,7 +325,9 @@ testCopy TestEnv{..} = do
325testCopyFailures :: TestEnv -> TestTree
325testCopyFailures :: TestEnv -> TestTree
326testCopyFailures env = testGroup "Copy failures"
326testCopyFailures env = testGroup "Copy failures"
327 $ map ($ env)
327 $ map ($ env)
328− [ testCopyUniqueConstraintError ]
328+ [ testCopyUniqueConstraintError
329+ , testCopyMalformedError
330goldenTest :: TestName -> IO BL.ByteString -> TestTree
332goldenTest :: TestName -> IO BL.ByteString -> TestTree
331goldenTest testName =
333goldenTest testName =
@@ -351,6 +353,20 @@ testCopyUniqueConstraintError TestEnv{..} =
351 ,"2,bar\n"
353 ,"2,bar\n"
352 ,"1,baz\n"]
354 ,"1,baz\n"]
356+testCopyMalformedError :: TestEnv -> TestTree
357+testCopyMalformedError TestEnv{..} =
358+ goldenTest "malformed input"
359+ $ handle (\(SomeException exc) -> return $ BL.pack $ show exc) $ do
360+ execute_ conn "CREATE TEMPORARY TABLE copy_malformed_input_error_test (x int PRIMARY KEY, y text)"
361+ copy_ conn "COPY copy_unique_constraint_error_test FROM STDIN (FORMAT CSV)"
362+ mapM_ (putCopyData conn) copyRows
363+ _n <- putCopyEnd conn
366+ copyRows = ["1,foo\n"
354testDouble :: TestEnv -> Assertion
370testDouble :: TestEnv -> Assertion
355testDouble TestEnv{..} = do
371testDouble TestEnv{..} = do
356 [Only (x :: Double)] <- query_ conn "SELECT 'NaN'::float8"
372 [Only (x :: Double)] <- query_ conn "SELECT 'NaN'::float8"