packages feed

persistent-postgresql 2.13.2.1 → 2.13.2.2

raw patch · 5 files changed

+28/−16 lines, 5 files

Files

ChangeLog.md view
@@ -1,5 +1,10 @@ # Changelog for persistent-postgresql +## 2.13.2.2++* [#1351](https://github.com/yesodweb/persistent/pull/1351/)+    * Support `aeson-2.0` in test suite.+ ## 2.13.2.1  * [#1331](https://github.com/yesodweb/persistent/pull/1331)
persistent-postgresql.cabal view
@@ -1,5 +1,5 @@ name:            persistent-postgresql-version:         2.13.2.1+version:         2.13.2.2 license:         MIT license-file:    LICENSE author:          Felipe Lessa, Michael Snoyman <michael@snoyman.com>
test/JSONTest.hs view
@@ -16,7 +16,7 @@ module JSONTest where  import Control.Monad.IO.Class (MonadIO)-import Data.Aeson+import Data.Aeson hiding (Key) import qualified Data.Vector as V (fromList) import Test.HUnit (assertBool) import Test.Hspec.Expectations ()
test/PgInit.hs view
@@ -27,6 +27,7 @@     , module Test.Hspec     , module Test.Hspec.Expectations.Lifted     , module Test.HUnit+    , AValue (..)     , BS.ByteString     , Int32, Int64     , liftIO@@ -68,7 +69,7 @@ import Control.Exception (SomeException) import Control.Monad (forM_, liftM, replicateM, void, when) import Control.Monad.Trans.Reader-import Data.Aeson (ToJSON, FromJSON, Value(..))+import Data.Aeson (ToJSON, FromJSON, Value(..), object) import Database.Persist.Postgresql.JSON () import Database.Persist.Sql.Raw.QQ import Database.Persist.SqlBackend@@ -117,6 +118,7 @@ import Data.Maybe (fromMaybe) import Data.Monoid ((<>)) import Data.Text (Text)+import Data.Vector (Vector) import System.Environment (getEnvironment) import System.Log.FastLogger (fromLogStr) @@ -204,19 +206,24 @@ runConnAssertUseConf actions = do   runResourceT $ runConnInternal RunConnConf (actions >> transactionUndo) -instance Arbitrary Value where-  arbitrary = frequency [ (1, pure Null)+newtype AValue = AValue { getValue :: Value }++-- Need a specialized Arbitrary instance+instance Arbitrary AValue where+  arbitrary = AValue <$>+              frequency [ (1, pure Null)                         , (1, Bool <$> arbitrary)                         , (2, Number <$> arbitrary)                         , (2, String <$> arbText)-                        , (3, Array <$> limitIt 4 arbitrary)-                        , (3, Object <$> arbObject)+                        , (3, Array <$> limitIt 4 (fmap (fmap getValue) arbitrary))+                        , (3, object <$> arbObject)                         ]-    where limitIt i x = sized $ \n -> do-            let m = if n > i then i else n-            resize m x-          arbObject = limitIt 4 -- Recursion can make execution divergent-                    $ fmap HM.fromList -- HashMap -> [(,)]-                    . listOf -- [(,)] -> (,)-                    . liftA2 (,) arbText -- (,) -> Text and Value-                    $ limitIt 4 arbitrary -- Again, precaution against divergent recursion.+    where+      limitIt :: Int -> Gen a -> Gen a+      limitIt i x = sized $ \n -> do+          let m = if n > i then i else n+          resize m x+      arbObject = limitIt 4 -- Recursion can make execution divergent+                $ listOf -- [(,)] -> (,)+                . liftA2 (,) arbText -- (,) -> Text and Value+                $ limitIt 4 (fmap getValue arbitrary) -- Again, precaution against divergent recursion.
test/main.hs view
@@ -99,7 +99,7 @@      <*> arbitrary              -- pico      <*> (arbitrary) -- utc      <*> (truncateUTCTime   =<< arbitrary) -- utc-     <*> arbitrary              -- value+     <*> fmap getValue arbitrary -- value  setup :: MonadIO m => Migration -> ReaderT SqlBackend m () setup migration = do