git.iko.soy/typeable/postgresql-simple
on master help sign in
Add test case for parsing arrays of nullable text.
commite547fae40d659458cd45597b538b7081a18480eb authorEdgar Gomes Araujo <talktoedgar@gmail.com> dateFri 10 Jun 2016, 17:06 (10 years ago) parent86ef90b
1 file changed+25−16
test/Main.hs+25−16
test/Main.hs+25−16
@@ -39,23 +39,24 @@ tests :: TestEnv -> TestTree
3939tests env = testGroup "tests"
4040 $ map ($ env)
4141 [ testBytea
42− , testCase "ExecuteMany" . testExecuteMany
43− , testCase "Fold" . testFold
44− , testCase "Notify" . testNotify
45− , testCase "Serializable" . testSerializable
46− , testCase "Time" . testTime
47− , testCase "Array" . testArray
48− , testCase "HStore" . testHStore
49− , testCase "JSON" . testJSON
50− , testCase "Savepoint" . testSavepoint
51− , testCase "Unicode" . testUnicode
52− , testCase "Values" . testValues
53− , testCase "Copy" . testCopy
42+ , testCase "ExecuteMany" . testExecuteMany
43+ , testCase "Fold" . testFold
44+ , testCase "Notify" . testNotify
45+ , testCase "Serializable" . testSerializable
46+ , testCase "Time" . testTime
47+ , testCase "Array" . testArray
48+ , testCase "Array of nullables" . testNullableArray
49+ , testCase "HStore" . testHStore
50+ , testCase "JSON" . testJSON
51+ , testCase "Savepoint" . testSavepoint
52+ , testCase "Unicode" . testUnicode
53+ , testCase "Values" . testValues
54+ , testCase "Copy" . testCopy
5455 , testCopyFailures
55− , testCase "Double" . testDouble
56− , testCase "1-ary generic" . testGeneric1
57− , testCase "2-ary generic" . testGeneric2
58− , testCase "3-ary generic" . testGeneric3
56+ , testCase "Double" . testDouble
57+ , testCase "1-ary generic" . testGeneric1
58+ , testCase "2-ary generic" . testGeneric2
59+ , testCase "3-ary generic" . testGeneric3
5960 ]
6061
6162testBytea :: TestEnv -> TestTree
@@ -177,6 +178,14 @@ testArray TestEnv{..} = do
177178 queryFailure conn "SELECT '{1,2,3,4}'::_int4" (undefined :: V.Vector Bool)
178179 queryFailure conn "SELECT '{{1,2},{3,4}}'::_int4" (undefined :: V.Vector Int)
179180
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+
180189testHStore :: TestEnv -> Assertion
181190testHStore TestEnv{..} = do
182191 execute_ conn "CREATE EXTENSION IF NOT EXISTS hstore"