Revision 3c002a13 htools/Ganeti/HTools/QC.hs

b/htools/Ganeti/HTools/QC.hs
34 34
    , testJobs
35 35
    , testCluster
36 36
    , testLoader
37
    , testTypes
37 38
    ) where
38 39

  
39 40
import Test.QuickCheck
......
265 266
      v <- choose (0, 1)
266 267
      return $ SmallRatio v
267 268

  
269
instance Arbitrary Types.AllocPolicy where
270
  arbitrary = elements [minBound..maxBound]
271

  
272
instance Arbitrary Types.DiskTemplate where
273
  arbitrary = elements [minBound..maxBound]
274

  
268 275
-- * Actual tests
269 276

  
270 277
-- ** Utils tests
......
956 963
  , run prop_Loader_assignIndices
957 964
  , run prop_Loader_mergeData
958 965
  ]
966

  
967
-- ** Types tests
968

  
969
prop_AllocPolicy_serialisation apol =
970
    case Types.apolFromString (Types.apolToString apol) of
971
      Types.Ok p -> printTestCase ("invalid deserialisation " ++ show p) $
972
                    p == apol
973
      Types.Bad s -> printTestCase ("failed to deserialise: " ++ s) False
974

  
975
prop_DiskTemplate_serialisation dt =
976
    case Types.dtFromString (Types.dtToString dt) of
977
      Types.Ok p -> printTestCase ("invalid deserialisation " ++ show p) $
978
                    p == dt
979
      Types.Bad s -> printTestCase ("failed to deserialise: " ++ s) False
980

  
981
testTypes =
982
    [ run prop_AllocPolicy_serialisation
983
    , run prop_DiskTemplate_serialisation
984
    ]

Also available in: Unified diff