git.iko.soy/typeable/postgresql-simple
on master help sign in
Add test/Fold.hs

If we switch to PostgreSQL parameterized queries in the future, this will break: query conn "FETCH FORWARD ? FROM fold" (Only chunkSize) PostgreSQL doesn't support parameter substitution here: > FETCH FORWARD $1 FROM c; ERROR: syntax error at or near "$1" LINE 1: FETCH FORWARD $1 FROM c; postgresql-simple constructs the query string itself, so this works for now.

commit2f9bf6fd96abd4ca2acb637185feb0fdbad3849c authorJoey Adams <joeyadams3.14159@gmail.com> dateSat 5 Jan 2013, 18:21 (14 years ago) parente4f2e4a
3 files changed+22
postgresql-simple.cabal+1 test/Fold.hs+19 test/Main.hs+2
postgresql-simple.cabal+1
@@ -80,6 +80,7 @@ test-suite test
8080 Common
8181 Bytea
8282 ExecuteMany
83+ Fold
8384 Notify
8485 Serializable
8586 Time
test/Fold.hsnew file+19
@@ -0,0 +1,19 @@
1+module Fold (testFold) where
2+
3+import Common
4+
5+testFold :: TestEnv -> Test
6+testFold TestEnv{..} = TestCase $ do
7+ xs <- fold_ conn "SELECT generate_series(1,10000)"
8+ [] $ \xs (Only x) -> return (x:xs)
9+ True <- return $ reverse xs == ([1..10000] :: [Int])
10+
11+ -- TODO: add more complete tests, e.g.:
12+ --
13+ -- * Fold in a transaction
14+ --
15+ -- * Fold in a transaction after a previous fold has been performed
16+ --
17+ -- * Nested fold
18+
19+ return ()
test/Main.hs+2
@@ -6,6 +6,7 @@ import System.IO
66
77import Bytea
88import ExecuteMany
9+import Fold
910import Notify
1011import Serializable
1112import Time
@@ -15,6 +16,7 @@ tests =
1516 [ TestLabel "Bytea" . testBytea
1617 , TestLabel "Notify" . testNotify
1718 , TestLabel "ExecuteMany" . testExecuteMany
19+ , TestLabel "Fold" . testFold
1820 , TestLabel "Time" . testTime
1921 , TestLabel "Serializable" . testSerializable
2022 ]