let str = intercalate "," $ map show (values::[Int])
in case CLI.parseISpecString descr str of
Types.Ok v -> failTest $ "Expected failure, got " ++ show v
- _ -> property True
+ _ -> passTest
-- | Test parseYesNo.
prop_parseYesNo :: Bool -> Bool -> [Char] -> Property
checkEarlyExit :: String -> [CLI.OptType] -> String -> Property
checkEarlyExit name options param =
case CLI.parseOptsInner [param] name options of
- Left (code, _) -> if code == 0
- then property True
- else failTest $ "Program " ++ name ++
- " returns invalid code " ++ show code ++
- " for option " ++ param
+ Left (code, _) ->
+ printTestCase ("Program " ++ name ++
+ " returns invalid code " ++ show code ++
+ " for option " ++ param) (code == 0)
_ -> failTest $ "Program " ++ name ++ " doesn't consider option " ++
param ++ " as early exit one"
[(if Instance.diskTemplate inst' == Types.DTDrbd8
then Instance.sNode
else Instance.pNode) inst'] of
- Types.Ok _ -> property True
+ Types.Ok _ -> passTest
Types.Bad msg -> failTest $ "Failed to relocate: " ++ msg
-- | Helper property checker for the result of a nodeEvac or
let inst' = setInstanceSmallerThanNode node inst
inst'' = inst' { Instance.vcpus = Node.availCpu node + extra }
in case Node.addPri node inst'' of
- Types.OpFail Types.FailCPU -> property True
+ Types.OpFail Types.FailCPU -> passTest
v -> failTest $ "Expected OpFail FailCPU, but got " ++ show v
-- | Check that an instance add with too high memory or disk will be
, Instance.mem = Node.availMem node + extra_mem
, Instance.vcpus = Node.availCpu node + extra_cpu }
in case Node.addPri node inst' of
- Types.OpGood _ -> property True
+ Types.OpGood _ -> passTest
v -> failTest $ "Expected OpGood, but got: " ++ show v
-- | Check that an offline instance with reasonable disk size but
, Instance.vcpus = Node.availCpu node + extra_cpu
, Instance.diskTemplate = Types.DTDrbd8 }
in case Node.addSec node inst' pdx of
- Types.OpGood _ -> property True
+ Types.OpGood _ -> passTest
v -> failTest $ "Expected OpGood/OpGood, but got: " ++ show v
-- | Checks for memory reservation changes.
-- poor man's instance Arbitrary JSValue
forAll (elements [J.showJSON i, J.showJSON s, J.showJSON b]) $ \item ->
case JSON.toArray item of
- BasicTypes.Bad _ -> property True
+ BasicTypes.Bad _ -> passTest
BasicTypes.Ok result -> failTest $ "Unexpected parse, got " ++ show result
testSuite "JSON"
failTest :: String -> Property
failTest msg = printTestCase msg False
+-- | A 'True' property.
+passTest :: Property
+passTest = property True
+
-- | Return the python binary to use. If the PYTHON environment
-- variable is defined, use its value, otherwise use just \"python\".
pythonCmd :: IO String