git.iko.soy/typeable/mandrill
on issue-14 help sign in
43 lines 1.7 kB history raw
1{-# LANGUAGE OverloadedStrings #-}
2module Main where
4import System.Environment
5import Data.Monoid
6import Tests
7import Online
8import Test.Tasty
9import Test.Tasty.HUnit
10import Test.Tasty.QuickCheck
11import qualified Data.Text as T
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 ]]
32----------------------------------------------------------------------
33main :: IO ()
34main = do
35 onlineTests <- onlineTestsIfEnabled
36 defaultMainWithIngredients defaultIngredients $
37 testGroup "Mandrill tests" $ onlineTests <> [
38 testGroup "Mandrill offline tests" [
39 testCase "users/info.json API parsing" testUsersInfo
40 , testCase "users/senders.json API parsing" testUsersSenders
41 , testCase "messages/send.json API parsing" testMessagesSend
42 ]
43 ]