Revision 8b5a517a htools/Ganeti/HTools/QC.hs

b/htools/Ganeti/HTools/QC.hs
38 38
  , testCluster
39 39
  , testLoader
40 40
  , testTypes
41
  , testCLI
41 42
  ) where
42 43

  
43 44
import Test.QuickCheck
......
1460 1461
            , 'prop_Types_opToResult
1461 1462
            , 'prop_Types_eitherToResult
1462 1463
            ]
1464

  
1465
-- ** CLI tests
1466

  
1467
-- | Test correct parsing.
1468
prop_CLI_parseISpec descr dsk mem cpu =
1469
  let str = printf "%d,%d,%d" dsk mem cpu
1470
  in CLI.parseISpecString descr str ==? Types.Ok (Types.RSpec cpu mem dsk)
1471

  
1472
-- | Test parsing failure due to wrong section count.
1473
prop_CLI_parseISpecFail descr =
1474
  forAll (choose (0,100) `suchThat` ((/=) 3)) $ \nelems ->
1475
  forAll (replicateM nelems arbitrary) $ \values ->
1476
  let str = intercalate "," $ map show (values::[Int])
1477
  in case CLI.parseISpecString descr str of
1478
       Types.Ok v -> failTest $ "Expected failure, got " ++ show v
1479
       _ -> property True
1480

  
1481
testSuite "CLI"
1482
          [ 'prop_CLI_parseISpec
1483
          , 'prop_CLI_parseISpecFail
1484
          ]

Also available in: Unified diff