packages feed

mangopay 1.9.4 → 1.9.5

raw patch · 2 files changed

+22/−7 lines, 2 filesdep +asyncPVP ok

version bump matches the API change (PVP)

Dependencies added: async

API changes (from Hackage documentation)

+ Web.MangoPay.TestUtils: withMangoPayTestUtils' :: (Credentials -> Manager -> IO a) -> IO a

Files

mangopay.cabal view
@@ -1,5 +1,5 @@ name:           mangopay-version:        1.9.4+version:        1.9.5 cabal-version:  >= 1.8 build-type:     Simple author:         JP Moresmau <jpmoresmau@gmail.com>@@ -56,6 +56,7 @@      , country-codes        == 0.1.*         -- Needed for TestUtils+     , async                >= 2.0      , blaze-builder      , HUnit                >= 1.2.5      , wai                  >= 3.0        && < 3.1@@ -107,7 +108,7 @@   main-is:         mangopay-tests.hs   ghc-options:     -Wall -rtsopts -threaded   build-depends:-     base, aeson, attoparsec, base16-bytestring,+     base, aeson, async, attoparsec, base16-bytestring,      base64-bytestring, blaze-builder, bytestring,      case-insensitive, conduit, data-default, http-conduit,      http-types, HUnit, lifted-base, monad-control, monad-logger,
src/Web/MangoPay/TestUtils.hs view
@@ -3,6 +3,7 @@ module Web.MangoPay.TestUtils   ( -- * Initialization     withMangoPayTestUtils+  , withMangoPayTestUtils'      -- * Test helpers   , testCardInfo1@@ -28,7 +29,6 @@ import Control.Monad.Logger (LoggingT, runStdoutLoggingT, logDebugS, logWarnS) import Control.Monad.Trans.Resource (ResourceT, runResourceT) import Data.Conduit (($$+-))-import Data.Default (def) import Data.Maybe (isJust) import Data.Monoid ((<>)) import Data.Text (Text)@@ -41,6 +41,7 @@  import Web.MangoPay +import qualified Control.Concurrent.Async as AS import qualified Data.ByteString.Lazy as BSL import qualified Network.HTTP.Conduit as H import qualified Data.Aeson as A@@ -245,7 +246,19 @@      -- ^ Action to run while being able to use functions from      -- this module.   -> IO a-withMangoPayTestUtils act =+withMangoPayTestUtils = withMangoPayTestUtils' . const . const+++-- | Same as 'withMangoPayTestUtils', but also gives more+-- information about the environment to the action.+withMangoPayTestUtils'+  :: (   Credentials+      -> H.Manager+      -> IO a )+     -- ^ Action to run while being able to use functions from+     -- this module.+  -> IO a+withMangoPayTestUtils' act =   H.withManager $ \mgr -> liftIO $ do     hook <- getHookEndPoint     res  <- newReceivedEvents@@ -257,7 +270,7 @@     bracket       (startHTTPServer hook res)       killThread-      (const $ initializeTestState >> act)+      (const $ initializeTestState >>= flip act mgr)   ----------------------------------------------------------------------@@ -346,7 +359,7 @@ -- (this file can be generated by mangopay-passphrase), -- generates a new id/name, keeps the same email and generates a new secret -- saves the secret to use in other tests.-initializeTestState :: IO ()+initializeTestState :: IO Credentials initializeTestState = do   mgr <- getTestHttpManager   creds <- createCredentials mgr@@ -355,6 +368,7 @@     ts { tsCredentials = creds        , tsAccessToken = toAccessToken at }   listenForAll+  return creds   -- | (Internal) Add the current time as a suffix to the client id@@ -398,7 +412,7 @@  -- | (Internal) Listen for all event types. listenForAll :: IO ()-listenForAll = mapM_ listenFor [minBound .. maxBound]+listenForAll = void $ AS.mapConcurrently listenFor [minBound .. maxBound]   -- | (Internal) Create a hook for a given event type.