Revision 76968973 test/hs/Test/Ganeti/Objects.hs

b/test/hs/Test/Ganeti/Objects.hs
530 530
  mapM_ (uncurry (HUnit.assertEqual "Different result after encoding/decoding")
531 531
        ) $ zip decoded instances
532 532

  
533
-- | Tests that the logical ID is correctly found in a plain disk
534
caseIncludeLogicalIdPlain :: HUnit.Assertion
535
caseIncludeLogicalIdPlain =
536
  let vg_name = "xenvg" :: String
537
      lv_name = "1234sdf-qwef-2134-asff-asd2-23145d.data" :: String
538
      d =
539
        Disk (LIDPlain vg_name lv_name) [] "diskname" 1000 DiskRdWr
540
          Nothing Nothing "asdfgr-1234-5123-daf3-sdfw-134f43"
541
  in
542
    HUnit.assertBool "Unable to detect that plain Disk includes logical ID" $
543
      includesLogicalId vg_name lv_name d
544

  
545
-- | Tests that the logical ID is correctly found in a DRBD disk
546
caseIncludeLogicalIdDrbd :: HUnit.Assertion
547
caseIncludeLogicalIdDrbd =
548
  let vg_name = "xenvg" :: String
549
      lv_name = "1234sdf-qwef-2134-asff-asd2-23145d.data" :: String
550
      d = 
551
        Disk
552
          (LIDDrbd8 "node1.example.com" "node2.example.com" 2000 1 5 "secret")
553
          [ Disk (LIDPlain "onevg" "onelv") [] "disk1" 1000 DiskRdWr Nothing
554
              Nothing "145145-asdf-sdf2-2134-asfd-534g2x"
555
          , Disk (LIDPlain vg_name lv_name) [] "disk2" 1000 DiskRdWr Nothing
556
              Nothing "6gd3sd-423f-ag2j-563b-dg34-gj3fse"
557
          ] "diskname" 1000 DiskRdWr Nothing Nothing
558
          "asdfgr-1234-5123-daf3-sdfw-134f43"
559
  in
560
    HUnit.assertBool "Unable to detect that plain Disk includes logical ID" $
561
      includesLogicalId vg_name lv_name d
562

  
563
-- | Tests that the logical ID is correctly NOT found in a plain disk
564
caseNotIncludeLogicalIdPlain :: HUnit.Assertion
565
caseNotIncludeLogicalIdPlain =
566
  let vg_name = "xenvg" :: String
567
      lv_name = "1234sdf-qwef-2134-asff-asd2-23145d.data" :: String
568
      d =
569
        Disk (LIDPlain "othervg" "otherlv") [] "diskname" 1000 DiskRdWr
570
          Nothing Nothing "asdfgr-1234-5123-daf3-sdfw-134f43"
571
  in
572
    HUnit.assertBool "Unable to detect that plain Disk includes logical ID" $
573
      not (includesLogicalId vg_name lv_name d)
574

  
533 575
testSuite "Objects"
534 576
  [ 'prop_fillDict
535 577
  , 'prop_Disk_serialisation
......
542 584
  , 'casePyCompatInstances
543 585
  , 'prop_nextIp4Address
544 586
  , 'caseNextIp4Address
587
  , 'caseIncludeLogicalIdPlain
588
  , 'caseIncludeLogicalIdDrbd
589
  , 'caseNotIncludeLogicalIdPlain
545 590
  ]

Also available in: Unified diff