git.iko.soy/typeable/mandrill
on release-0.5.2.1 help sign in
70 lines 2.1 kB history raw
1{-# LANGUAGE OverloadedStrings #-}
2module Online where
4import Data.Aeson
5import qualified Data.ByteString.Char8 as C8
6import Data.Either
7import Network.API.Mandrill.Messages.Types
8import Network.API.Mandrill.Users.Types
9import RawData
10import Test.QuickCheck
11import Test.Tasty.HUnit
12import Text.RawString.QQ
14import qualified Network.API.Mandrill.Inbound as API
15import qualified Network.API.Mandrill.Messages as API
16import Network.API.Mandrill.Types
17import qualified Network.API.Mandrill.Users as API
19--
20-- Users calls
21--
22testOnlineUsersInfo :: MandrillKey -> Assertion
23testOnlineUsersInfo k = do
24 res <- API.info k Nothing
25 case res of
26 MandrillSuccess _ -> return ()
27 MandrillFailure e -> fail $ "users/info.json " ++ show e
29testOnlineUsersPing2 :: MandrillKey -> Assertion
30testOnlineUsersPing2 k = do
31 res <- API.ping2 k Nothing
32 case res of
33 MandrillSuccess _ -> return ()
34 MandrillFailure e -> fail $ "users/ping2.json " ++ show e
36testOnlineUsersSenders :: MandrillKey -> Assertion
37testOnlineUsersSenders k = do
38 res <- API.senders k Nothing
39 case res of
40 MandrillSuccess _ -> return ()
41 MandrillFailure e -> fail $ "users/senders.json " ++ show e
44--
45-- Messages calls
46--
47testOnlineMessagesSend :: MandrillKey -> Assertion
48testOnlineMessagesSend k = do
49 msg <- generate arbitrary
50 res <- API.send k msg Nothing Nothing Nothing Nothing
51 case res of
52 MandrillSuccess _ -> return ()
53 MandrillFailure e -> fail $ "messages/send.json " ++ show e
55--
56-- Inbound calls
57--
58testOnlineDomainAdd :: MandrillKey -> Assertion
59testOnlineDomainAdd k = do
60 res <- API.addDomain k "foobar.com" Nothing
61 case res of
62 MandrillSuccess a -> print a
63 MandrillFailure e -> fail $ "inbound/add-domain.json " ++ show e
65testOnlineRouteAdd :: MandrillKey -> Assertion
66testOnlineRouteAdd k = do
67 res <- API.addRoute k "foobar.com" "mail-*" "http://requestb.in/19a4frw1" Nothing
68 case res of
69 MandrillSuccess a -> print a
70 MandrillFailure e -> fail $ "inbound/add-domain.json " ++ show e