module Test.Ganeti.Daemon (testDaemon) where
import Test.QuickCheck hiding (Result)
import Test.HUnit
import Test.Ganeti.TestHelper
import Test.Ganeti.TestCommon
import Test.Ganeti.Common
import Ganeti.Common
import Ganeti.Daemon as Daemon
prop_string_arg :: String -> Property
prop_string_arg argument =
let args = [ (argument, oBindAddress, optBindAddress)
]
in conjoin $
map (checkOpt Just defaultOptions failTest (const (==?)) Just) args
prop_numeric_arg :: Int -> Property
prop_numeric_arg argument =
checkOpt (Just . show) defaultOptions
failTest (const (==?)) (Just . fromIntegral)
(argument, oPort 0, optPort)
case_bool_arg :: Assertion
case_bool_arg =
mapM_ (checkOpt (const Nothing) defaultOptions assertFailure
assertEqual id)
[ (False, oNoDaemonize, optDaemonize)
, (True, oDebug, optDebug)
, (True, oNoUserChecks, optNoUserChecks)
]
case_wrong_arg :: Assertion
case_wrong_arg =
mapM_ (passFailOpt defaultOptions assertFailure (return ()))
[ (oSyslogUsage, "foo", "yes")
, (oPort 0, "x", "10")
]
case_stdopts :: Assertion
case_stdopts =
checkEarlyExit defaultOptions "prog" [oShowHelp, oShowVer] []
testSuite "Daemon"
[ 'prop_string_arg
, 'prop_numeric_arg
, 'case_bool_arg
, 'case_wrong_arg
, 'case_stdopts
]