@@ -604,15 +604,13 @@ func TestGetRequestCapacity(t *testing.T) {
604
604
func TestDiskIsAttached (t * testing.T ) {
605
605
testCases := []struct {
606
606
name string
607
- disk * compute. Disk
607
+ deviceName string
608
608
instance * compute.Instance
609
609
expAttached bool
610
610
}{
611
611
{
612
- name : "normal-attached" ,
613
- disk : & compute.Disk {
614
- Name : "test-disk" ,
615
- },
612
+ name : "normal-attached" ,
613
+ deviceName : "test-disk" ,
616
614
instance : & compute.Instance {
617
615
Disks : []* compute.AttachedDisk {
618
616
{
@@ -623,10 +621,8 @@ func TestDiskIsAttached(t *testing.T) {
623
621
expAttached : true ,
624
622
},
625
623
{
626
- name : "normal-not-attached" ,
627
- disk : & compute.Disk {
628
- Name : "test-disk" ,
629
- },
624
+ name : "normal-not-attached" ,
625
+ deviceName : "test-disk" ,
630
626
instance : & compute.Instance {
631
627
Disks : []* compute.AttachedDisk {
632
628
{
@@ -639,7 +635,7 @@ func TestDiskIsAttached(t *testing.T) {
639
635
}
640
636
for _ , tc := range testCases {
641
637
t .Logf ("test case: %s" , tc .name )
642
- if attached := diskIsAttached (gce . ZonalCloudDisk ( tc .disk ) , tc .instance ); attached != tc .expAttached {
638
+ if attached := diskIsAttached (tc .deviceName , tc .instance ); attached != tc .expAttached {
643
639
t .Errorf ("Expected disk attached to be %v, but got %v" , tc .expAttached , attached )
644
640
}
645
641
}
@@ -648,17 +644,15 @@ func TestDiskIsAttached(t *testing.T) {
648
644
func TestDiskIsAttachedAndCompatible (t * testing.T ) {
649
645
testCases := []struct {
650
646
name string
651
- disk * compute. Disk
647
+ deviceName string
652
648
instance * compute.Instance
653
649
mode string
654
650
expAttached bool
655
651
expErr bool
656
652
}{
657
653
{
658
- name : "normal-attached" ,
659
- disk : & compute.Disk {
660
- Name : "test-disk" ,
661
- },
654
+ name : "normal-attached" ,
655
+ deviceName : "test-disk" ,
662
656
instance : & compute.Instance {
663
657
Disks : []* compute.AttachedDisk {
664
658
{
@@ -671,10 +665,8 @@ func TestDiskIsAttachedAndCompatible(t *testing.T) {
671
665
expAttached : true ,
672
666
},
673
667
{
674
- name : "normal-not-attached" ,
675
- disk : & compute.Disk {
676
- Name : "test-disk" ,
677
- },
668
+ name : "normal-not-attached" ,
669
+ deviceName : "test-disk" ,
678
670
instance : & compute.Instance {
679
671
Disks : []* compute.AttachedDisk {
680
672
{
@@ -687,10 +679,8 @@ func TestDiskIsAttachedAndCompatible(t *testing.T) {
687
679
expAttached : false ,
688
680
},
689
681
{
690
- name : "incompatible mode" ,
691
- disk : & compute.Disk {
692
- Name : "test-disk" ,
693
- },
682
+ name : "incompatible mode" ,
683
+ deviceName : "test-disk" ,
694
684
instance : & compute.Instance {
695
685
Disks : []* compute.AttachedDisk {
696
686
{
@@ -706,7 +696,7 @@ func TestDiskIsAttachedAndCompatible(t *testing.T) {
706
696
}
707
697
for _ , tc := range testCases {
708
698
t .Logf ("test case: %s" , tc .name )
709
- attached , err := diskIsAttachedAndCompatible (gce . ZonalCloudDisk ( tc .disk ) , tc .instance , nil , tc .mode )
699
+ attached , err := diskIsAttachedAndCompatible (tc .deviceName , tc .instance , nil , tc .mode )
710
700
if err != nil && ! tc .expErr {
711
701
t .Errorf ("Did not expect error but got: %v" , err )
712
702
}
0 commit comments