git.iko.soy/typeable/postgresql-simple
on master help sign in
Add test case for parsing arrays of nullable text.
e547faeEdgar Gomes Araujo
test/Main.hs+25−16
@@ -39,23 +39,24 @@ tests :: TestEnv -> TestTree
39tests env = testGroup "tests"
39tests env = testGroup "tests"
40 $ map ($ env)
40 $ map ($ env)
41 [ testBytea
41 [ testBytea
42− , testCase "ExecuteMany" . testExecuteMany
42+ , testCase "ExecuteMany" . testExecuteMany
43− , testCase "Fold" . testFold
43+ , testCase "Fold" . testFold
44− , testCase "Notify" . testNotify
44+ , testCase "Notify" . testNotify
45− , testCase "Serializable" . testSerializable
45+ , testCase "Serializable" . testSerializable
46− , testCase "Time" . testTime
46+ , testCase "Time" . testTime
47− , testCase "Array" . testArray
47+ , testCase "Array" . testArray
48+ , testCase "Array of nullables" . testNullableArray
48− , testCase "HStore" . testHStore
49+ , testCase "HStore" . testHStore
49− , testCase "JSON" . testJSON
50+ , testCase "JSON" . testJSON
50− , testCase "Savepoint" . testSavepoint
51+ , testCase "Savepoint" . testSavepoint
51− , testCase "Unicode" . testUnicode
52+ , testCase "Unicode" . testUnicode
52− , testCase "Values" . testValues
53+ , testCase "Values" . testValues
53− , testCase "Copy" . testCopy
54+ , testCase "Copy" . testCopy
54 , testCopyFailures
55 , testCopyFailures
55− , testCase "Double" . testDouble
56+ , testCase "Double" . testDouble
56− , testCase "1-ary generic" . testGeneric1
57+ , testCase "1-ary generic" . testGeneric1
57− , testCase "2-ary generic" . testGeneric2
58+ , testCase "2-ary generic" . testGeneric2
58− , testCase "3-ary generic" . testGeneric3
59+ , testCase "3-ary generic" . testGeneric3
59 ]
60 ]
60
61
61testBytea :: TestEnv -> TestTree
62testBytea :: TestEnv -> TestTree
@@ -177,6 +178,14 @@ testArray TestEnv{..} = do
177 queryFailure conn "SELECT '{1,2,3,4}'::_int4" (undefined :: V.Vector Bool)
178 queryFailure conn "SELECT '{1,2,3,4}'::_int4" (undefined :: V.Vector Bool)
178 queryFailure conn "SELECT '{{1,2},{3,4}}'::_int4" (undefined :: V.Vector Int)
179 queryFailure conn "SELECT '{{1,2},{3,4}}'::_int4" (undefined :: V.Vector Int)
179
180
181+testNullableArray :: TestEnv -> Assertion
182+testNullableArray TestEnv{..} = do
183+ xs <- query_ conn "SELECT '{sometext, \"NULL\"}'::_text"
184+ xs @?= [Only (V.fromList ["sometext", "NULL" :: Text])]
185+ xs <- query_ conn "SELECT '{sometext, NULL}'::_text"
186+ xs @?= [Only (V.fromList [Just "sometext", Nothing :: Maybe Text])]
187+ queryFailure conn "SELECT '{sometext, NULL}'::_text" (undefined :: V.Vector Text)
188+
180testHStore :: TestEnv -> Assertion
189testHStore :: TestEnv -> Assertion
181testHStore TestEnv{..} = do
190testHStore TestEnv{..} = do
182 execute_ conn "CREATE EXTENSION IF NOT EXISTS hstore"
191 execute_ conn "CREATE EXTENSION IF NOT EXISTS hstore"