Revision 89298c04
b/htools/Ganeti/HTools/QC.hs | ||
---|---|---|
47 | 47 |
import qualified Data.Set as Set |
48 | 48 |
import Data.Maybe |
49 | 49 |
import Control.Monad |
50 |
import qualified System.Console.GetOpt as GetOpt |
|
50 | 51 |
import qualified Text.JSON as J |
51 | 52 |
import qualified Data.Map |
52 | 53 |
import qualified Data.IntMap as IntMap |
54 |
|
|
53 | 55 |
import qualified Ganeti.OpCodes as OpCodes |
54 | 56 |
import qualified Ganeti.Jobs as Jobs |
55 | 57 |
import qualified Ganeti.Luxi |
... | ... | |
1488 | 1490 |
then result ==? Types.Ok (actual_val == "yes") |
1489 | 1491 |
else property $ Types.isBad result |
1490 | 1492 |
|
1493 |
-- | Helper to check for correct parsing of string arg. |
|
1494 |
checkStringArg val (opt, fn) = |
|
1495 |
let GetOpt.Option _ longs _ _ = opt |
|
1496 |
in case longs of |
|
1497 |
[] -> failTest "no long options?" |
|
1498 |
cmdarg:_ -> |
|
1499 |
case CLI.parseOptsInner ["--" ++ cmdarg ++ "=" ++ val] "prog" [opt] of |
|
1500 |
Left e -> failTest $ "Failed to parse option: " ++ show e |
|
1501 |
Right (options, _) -> fn options ==? Just val |
|
1502 |
|
|
1503 |
-- | Test a few string arguments. |
|
1504 |
prop_CLI_StringArg argument = |
|
1505 |
let args = [ (CLI.oDataFile, CLI.optDataFile) |
|
1506 |
, (CLI.oDynuFile, CLI.optDynuFile) |
|
1507 |
, (CLI.oSaveCluster, CLI.optSaveCluster) |
|
1508 |
, (CLI.oReplay, CLI.optReplay) |
|
1509 |
, (CLI.oPrintCommands, CLI.optShowCmds) |
|
1510 |
, (CLI.oLuxiSocket, CLI.optLuxi) |
|
1511 |
] |
|
1512 |
in conjoin $ map (checkStringArg argument) args |
|
1513 |
|
|
1491 | 1514 |
testSuite "CLI" |
1492 | 1515 |
[ 'prop_CLI_parseISpec |
1493 | 1516 |
, 'prop_CLI_parseISpecFail |
1494 | 1517 |
, 'prop_CLI_parseYesNo |
1518 |
, 'prop_CLI_StringArg |
|
1495 | 1519 |
] |
Also available in: Unified diff