@@ -18,6 +18,7 @@ module Spec (specTests) where
19import Control.Concurrent.Async (replicateConcurrently)
19import Control.Concurrent.Async (replicateConcurrently)
20import Data.ByteString (ByteString)
20import Data.ByteString (ByteString)
21+import Data.Int (Int32)
21import Data.Text (Text)
22import Data.Text (Text)
22import Test.Hspec
23import Test.Hspec
@@ -89,7 +90,7 @@ spec = before_ setupDB . after_ dropDB $ do
89 withConnection connectionString (transactionally_ insertUserTwice)
90 withConnection connectionString (transactionally_ insertUserTwice)
90 `shouldThrow` (== err23505)
91 `shouldThrow` (== err23505)
92− describe "Pools" $ do
93+ describe "Pools" $
94 it "should manage concurrent transactions" $ do
95 it "should manage concurrent transactions" $ do
95 pool <- createConnectionPool
96 pool <- createConnectionPool
@@ -102,7 +103,23 @@ spec = before_ setupDB . after_ dropDB $ do
102 Just (Only chr) <- firstRow result
103 Just (Only chr) <- firstRow result
103 return chr
104 return chr
104 chrs <- replicateConcurrently 10 session
105 chrs <- replicateConcurrently 10 session
105− chrs `shouldSatisfy` (all (== 'a'))
106+ chrs `shouldSatisfy` all (== 'a')
110+ it "should correctly decode ranges" $ do
112+ rangesOut <- withConnection connectionString $ do
114+ query :: Query_ (Public '[]) () (Only (Range Int32))
116+ ( range int4range (atLeast 3) `as` #fromOnly )
117+ [ range int4range (3 <=..< 5) `as` #fromOnly
118+ , range int4range Empty `as` #fromOnly
119+ , range int4range whole `as` #fromOnly ]
120+ getRows =<< runQuery query
121+ (fromOnly <$> rangesOut :: [Range Int32]) `shouldBe`
122+ [ atLeast 3, 3 <=..< 5, Empty, whole ]
107specTests :: IO ()
124specTests :: IO ()
108specTests = hspec spec
125specTests = hspec spec