Revision aa1d552d

b/htools/Ganeti/HTools/QC.hs
367 367
instance Arbitrary Types.FailMode where
368 368
  arbitrary = elements [minBound..maxBound]
369 369

  
370
instance Arbitrary Types.EvacMode where
371
  arbitrary = elements [minBound..maxBound]
372

  
370 373
instance Arbitrary a => Arbitrary (Types.OpResult a) where
371 374
  arbitrary = arbitrary >>= \c ->
372 375
              if c
......
1253 1256

  
1254 1257
prop_Types_AllocPolicy_serialisation apol =
1255 1258
  case J.readJSON (J.showJSON apol) of
1256
    J.Ok p -> printTestCase ("invalid deserialisation " ++ show p) $
1257
              p == apol
1259
    J.Ok p -> p ==? apol
1258 1260
    J.Error s -> printTestCase ("failed to deserialise: " ++ s) False
1259 1261
      where _types = apol::Types.AllocPolicy
1260 1262

  
1261 1263
prop_Types_DiskTemplate_serialisation dt =
1262 1264
  case J.readJSON (J.showJSON dt) of
1263
    J.Ok p -> printTestCase ("invalid deserialisation " ++ show p) $
1264
              p == dt
1265
    J.Ok p -> p ==? dt
1265 1266
    J.Error s -> printTestCase ("failed to deserialise: " ++ s)
1266 1267
                 False
1267 1268
      where _types = dt::Types.DiskTemplate
1268 1269

  
1270
prop_Types_ISpec_serialisation ispec =
1271
  case J.readJSON (J.showJSON ispec) of
1272
    J.Ok p -> p ==? ispec
1273
    J.Error s -> printTestCase ("failed to deserialise: " ++ s)
1274
                 False
1275
      where _types = ispec::Types.ISpec
1276

  
1277
prop_Types_IPolicy_serialisation ipol =
1278
  case J.readJSON (J.showJSON ipol) of
1279
    J.Ok p -> p ==? ipol
1280
    J.Error s -> printTestCase ("failed to deserialise: " ++ s)
1281
                 False
1282
      where _types = ipol::Types.IPolicy
1283

  
1284
prop_Types_EvacMode_serialisation em =
1285
  case J.readJSON (J.showJSON em) of
1286
    J.Ok p -> p ==? em
1287
    J.Error s -> printTestCase ("failed to deserialise: " ++ s)
1288
                 False
1289
      where _types = em::Types.EvacMode
1290

  
1269 1291
prop_Types_opToResult op =
1270 1292
  case op of
1271 1293
    Types.OpFail _ -> Types.isBad r
......
1287 1309
testSuite "Types"
1288 1310
            [ 'prop_Types_AllocPolicy_serialisation
1289 1311
            , 'prop_Types_DiskTemplate_serialisation
1312
            , 'prop_Types_ISpec_serialisation
1313
            , 'prop_Types_IPolicy_serialisation
1314
            , 'prop_Types_EvacMode_serialisation
1290 1315
            , 'prop_Types_opToResult
1291 1316
            , 'prop_Types_eitherToResult
1292 1317
            ]

Also available in: Unified diff