Safe Haskell | None |
---|
- withMangoPayTestUtils :: IO a -> IO a
- withMangoPayTestUtils' :: (Credentials -> Manager -> IO a) -> IO a
- testCardInfo1 :: CardInfo
- testMP :: (AccessToken -> MangoPayT (LoggingT (ResourceT IO)) b) -> IO b
- testEventTypes :: [EventType] -> IO (Maybe Text) -> Assertion
- testEventTypes' :: [EventType] -> IO (Maybe Text) -> IO (Maybe Text)
- unsafeFullRegistration :: MPUsableMonad m => AnyUserId -> Currency -> CardInfo -> AccessToken -> MangoPayT m CardRegistration
- unsafeRegisterCard :: CardInfo -> CardRegistration -> IO CardRegistration
- ensureNoEvents :: Int -> Assertion
Initialization
:: IO a | Action to run while being able to use functions from this module. |
-> IO a |
Creates and initializes the MangoPay infrastructure needed to use the test helpers from this module. Tears down the server at the end.
You may want to use ensureNoEvents
at the end of your action
before tearing down the server.
This module uses global, shared state. You have to wrap your
entire test suite with this function, and you can't use
withMangoPayTests
more than once.
Reads two files from the current directory:
:: (Credentials -> Manager -> IO a) | Action to run while being able to use functions from this module. |
-> IO a |
Same as withMangoPayTestUtils
, but also gives more
information about the environment to the action.
Test helpers
testCardInfo1 :: CardInfoSource
A test card.
testMP :: (AccessToken -> MangoPayT (LoggingT (ResourceT IO)) b) -> IO bSource
Test MangoPay API call, logging in with the client
credentials. Expects a file called client.test.conf
containing the JSON of client credentials in the current
directory.
testEventTypes :: [EventType] -> IO (Maybe Text) -> AssertionSource
Run the given test, then check that we've received events of the given types which reference resource id returned by the test.
testEventTypes' :: [EventType] -> IO (Maybe Text) -> IO (Maybe Text)Source
Same as testEventTypes
, but also return the resource id.
Credit card registration
unsafeFullRegistration :: MPUsableMonad m => AnyUserId -> Currency -> CardInfo -> AccessToken -> MangoPayT m CardRegistrationSource
Perform the full registration of a card.
This function is UNSAFE, because if you use this, YOU handle the user's credit card details so you need to be PCI compliant!
unsafeRegisterCard :: CardInfo -> CardRegistration -> IO CardRegistrationSource
Register a card with the registration URL.
This function is UNSAFE, because if you use this, YOU handle the user's credit card details so you need to be PCI compliant!
XXX This is not working anymore.
Tear down
ensureNoEvents :: Int -> AssertionSource
Wait for the given number of seconds and check if any MangoPay event has arrived. Fails if so. Use this function at the end of your test run to ensure that you're aware of every MangoPay event.