From dd77da99042407249f3133b2d18222fa018820c9 Mon Sep 17 00:00:00 2001 From: Helga Velroyen Date: Mon, 22 Oct 2012 11:28:22 +0200 Subject: [PATCH] A few unittests improvements Small simplifications of other unit tests using the (==?) operator when possible, and typo fixes. Signed-off-by: Helga Velroyen Reviewed-by: Iustin Pop --- htest/Test/Ganeti/HTools/Node.hs | 10 +++------- htools/Ganeti/HTools/Program/Hspace.hs | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/htest/Test/Ganeti/HTools/Node.hs b/htest/Test/Ganeti/HTools/Node.hs index 7d32abf..9631dd1 100644 --- a/htest/Test/Ganeti/HTools/Node.hs +++ b/htest/Test/Ganeti/HTools/Node.hs @@ -53,7 +53,7 @@ import qualified Ganeti.HTools.Types as Types -- * Arbitrary instances --- | Generas an arbitrary node based on sizing information. +-- | Generates an arbitrary node based on sizing information. genNode :: Maybe Int -- ^ Minimum node size in terms of units -> Maybe Int -- ^ Maximum node size (when Nothing, bounded -- just by the max... constants) @@ -126,9 +126,7 @@ prop_addPriFM :: Node.Node -> Instance.Instance -> Property prop_addPriFM node inst = Instance.mem inst >= Node.fMem node && not (Node.failN1 node) && not (Instance.isOffline inst) ==> - case Node.addPri node inst'' of - Bad Types.FailMem -> True - _ -> False + (Node.addPri node inst'' ==? Bad Types.FailMem) where inst' = setInstanceSmallerThanNode node inst inst'' = inst' { Instance.mem = Instance.mem inst } @@ -141,9 +139,7 @@ prop_addPriFD node inst = let inst' = setInstanceSmallerThanNode node inst inst'' = inst' { Instance.dsk = Instance.dsk inst , Instance.diskTemplate = dt } - in case Node.addPri node inst'' of - Bad Types.FailDisk -> True - _ -> False + in (Node.addPri node inst'' ==? Bad Types.FailDisk) -- | Check that adding a primary instance with too many VCPUs fails -- with type FailCPU. diff --git a/htools/Ganeti/HTools/Program/Hspace.hs b/htools/Ganeti/HTools/Program/Hspace.hs index 9ad61b8..6dd4905 100644 --- a/htools/Ganeti/HTools/Program/Hspace.hs +++ b/htools/Ganeti/HTools/Program/Hspace.hs @@ -122,7 +122,7 @@ cpuEff :: Cluster.CStats -> Double cpuEff = effFn Cluster.csIcpu (fromIntegral . Cluster.csVcpu) -- | Holds data for converting a 'Cluster.CStats' structure into --- detailed statictics. +-- detailed statistics. statsData :: [(String, Cluster.CStats -> String)] statsData = [ ("SCORE", printf "%.8f" . Cluster.csScore) , ("INST_CNT", printf "%d" . Cluster.csNinst) -- 1.7.10.4