Revision 6429e8d8 htools/Ganeti/HTools/QC.hs

b/htools/Ganeti/HTools/QC.hs
506 506

  
507 507
prop_Text_Load_Instance name mem dsk vcpus status
508 508
                        (NonEmpty pnode) snode
509
                        (NonNegative pdx) (NonNegative sdx) autobal =
509
                        (NonNegative pdx) (NonNegative sdx) autobal dt =
510 510
    pnode /= snode && pdx /= sdx ==>
511 511
    let vcpus_s = show vcpus
512 512
        dsk_s = show dsk
......
517 517
        nl = Data.Map.fromList ndx
518 518
        tags = ""
519 519
        sbal = if autobal then "Y" else "N"
520
        sdt = Types.dtToString dt
520 521
        inst = Text.loadInst nl
521 522
               [name, mem_s, dsk_s, vcpus_s, status,
522
                sbal, pnode, snode, tags]:: Maybe (String, Instance.Instance)
523
                sbal, pnode, snode, sdt, tags]
523 524
        fail1 = Text.loadInst nl
524 525
               [name, mem_s, dsk_s, vcpus_s, status,
525
                sbal, pnode, pnode, tags]:: Maybe (String, Instance.Instance)
526
                sbal, pnode, pnode, tags]
526 527
        _types = ( name::String, mem::Int, dsk::Int
527 528
                 , vcpus::Int, status::String
528 529
                 , snode::String
529 530
                 , autobal::Bool)
530 531
    in
531 532
      case inst of
532
        Nothing -> False
533
        Just (_, i) ->
533
        Types.Bad msg -> printTestCase ("Failed to load instance: " ++ msg)
534
                         False
535
        Types.Ok (_, i) -> printTestCase ("Mismatch in some field while\
536
                                          \ loading the instance") $
534 537
            Instance.name i == name &&
535 538
            Instance.vcpus i == vcpus &&
536 539
            Instance.mem i == mem &&
......
539 542
                                 then Node.noSecondary
540 543
                                 else sdx) &&
541 544
            Instance.autoBalance i == autobal &&
542
            isNothing fail1
545
            Types.isBad fail1
543 546

  
544 547
prop_Text_Load_InstanceFail ktn fields =
545
    length fields /= 9 ==>
548
    length fields /= 10 ==>
546 549
    case Text.loadInst nl fields of
547
      Types.Ok _ -> False
548
      Types.Bad msg -> "Invalid/incomplete instance data: '" `isPrefixOf` msg
550
      Types.Ok _ -> printTestCase "Managed to load instance from invalid\
551
                                  \ data" False
552
      Types.Bad msg -> printTestCase ("Unrecognised error message: " ++ msg) $
553
                       "Invalid/incomplete instance data: '" `isPrefixOf` msg
549 554
    where nl = Data.Map.fromList ktn
550 555

  
551 556
prop_Text_Load_Node name tm nm fm td fd tc fo =

Also available in: Unified diff