git.iko.soy/typeable/mandrill
on master help sign in
50 lines 2.3 kB history raw
1{-# LANGUAGE OverloadedStrings #-}
2module Main where
4import Data.Monoid
5import qualified Data.Text as T
6import Online
7import System.Environment
8import Test.Tasty
9import Test.Tasty.HUnit
10import Test.Tasty.QuickCheck
11import Tests
13----------------------------------------------------------------------
14withQuickCheckDepth :: TestName -> Int -> [TestTree] -> TestTree
15withQuickCheckDepth tn depth tests =
16 localOption (QuickCheckTests depth) (testGroup tn tests)
18----------------------------------------------------------------------
19onlineTestsIfEnabled :: IO [TestTree]
20onlineTestsIfEnabled = do
21 apiKey <- (return . fmap T.pack) =<< lookupEnv "MANDRILL_API_KEY"
22 case apiKey of
23 Nothing -> return []
24 Just k -> return [
25 testGroup "Mandrill online tests" [
26 testCase "users/info.json" (testOnlineUsersInfo k)
27 , testCase "users/ping2.json" (testOnlineUsersPing2 k)
28 , testCase "users/senders.json" (testOnlineUsersSenders k)
29 , testCase "messages/send.json" (testOnlineMessagesSend k)
30 , testCase "inbound/addDomain.json" (testOnlineDomainAdd k)
31 , testCase "inbound/addRoute.json" (testOnlineRouteAdd k)
32 ]]
34----------------------------------------------------------------------
35main :: IO ()
36main = do
37 onlineTests <- onlineTestsIfEnabled
38 defaultMainWithIngredients defaultIngredients $
39 testGroup "Mandrill tests" $ onlineTests <> [
40 testGroup "Mandrill offline tests" [
41 testCase "users/info.json API parsing" testUsersInfo
42 , testCase "users/senders.json API parsing" testUsersSenders
43 , testCase "messages/send.json API parsing" testMessagesSend
44 , testCase "messages/send.json API response parsing" testMessagesResponseRejected
45 , testCase "inbound/add-route.json API response parsing" testRouteAdd
46 , testCase "inbound/add-domain.json API response parsing" testDomainAdd
47 , testCase "senders/verify-domain.json API response parsing" testVerifyDomain
48 , testCase "webhooks/add.json API response parsing" testWebhookAdd
49 ]
50 ]