@@ -849,15 +849,13 @@ func TestGetRequestCapacity(t *testing.T) {
849
849
func TestDiskIsAttached (t * testing.T ) {
850
850
testCases := []struct {
851
851
name string
852
- disk * compute. Disk
852
+ deviceName string
853
853
instance * compute.Instance
854
854
expAttached bool
855
855
}{
856
856
{
857
- name : "normal-attached" ,
858
- disk : & compute.Disk {
859
- Name : "test-disk" ,
860
- },
857
+ name : "normal-attached" ,
858
+ deviceName : "test-disk" ,
861
859
instance : & compute.Instance {
862
860
Disks : []* compute.AttachedDisk {
863
861
{
@@ -868,10 +866,8 @@ func TestDiskIsAttached(t *testing.T) {
868
866
expAttached : true ,
869
867
},
870
868
{
871
- name : "normal-not-attached" ,
872
- disk : & compute.Disk {
873
- Name : "test-disk" ,
874
- },
869
+ name : "normal-not-attached" ,
870
+ deviceName : "test-disk" ,
875
871
instance : & compute.Instance {
876
872
Disks : []* compute.AttachedDisk {
877
873
{
@@ -884,7 +880,7 @@ func TestDiskIsAttached(t *testing.T) {
884
880
}
885
881
for _ , tc := range testCases {
886
882
t .Logf ("test case: %s" , tc .name )
887
- if attached := diskIsAttached (gce . ZonalCloudDisk ( tc .disk ) , tc .instance ); attached != tc .expAttached {
883
+ if attached := diskIsAttached (tc .deviceName , tc .instance ); attached != tc .expAttached {
888
884
t .Errorf ("Expected disk attached to be %v, but got %v" , tc .expAttached , attached )
889
885
}
890
886
}
@@ -893,17 +889,15 @@ func TestDiskIsAttached(t *testing.T) {
893
889
func TestDiskIsAttachedAndCompatible (t * testing.T ) {
894
890
testCases := []struct {
895
891
name string
896
- disk * compute. Disk
892
+ deviceName string
897
893
instance * compute.Instance
898
894
mode string
899
895
expAttached bool
900
896
expErr bool
901
897
}{
902
898
{
903
- name : "normal-attached" ,
904
- disk : & compute.Disk {
905
- Name : "test-disk" ,
906
- },
899
+ name : "normal-attached" ,
900
+ deviceName : "test-disk" ,
907
901
instance : & compute.Instance {
908
902
Disks : []* compute.AttachedDisk {
909
903
{
@@ -916,10 +910,8 @@ func TestDiskIsAttachedAndCompatible(t *testing.T) {
916
910
expAttached : true ,
917
911
},
918
912
{
919
- name : "normal-not-attached" ,
920
- disk : & compute.Disk {
921
- Name : "test-disk" ,
922
- },
913
+ name : "normal-not-attached" ,
914
+ deviceName : "test-disk" ,
923
915
instance : & compute.Instance {
924
916
Disks : []* compute.AttachedDisk {
925
917
{
@@ -932,10 +924,8 @@ func TestDiskIsAttachedAndCompatible(t *testing.T) {
932
924
expAttached : false ,
933
925
},
934
926
{
935
- name : "incompatible mode" ,
936
- disk : & compute.Disk {
937
- Name : "test-disk" ,
938
- },
927
+ name : "incompatible mode" ,
928
+ deviceName : "test-disk" ,
939
929
instance : & compute.Instance {
940
930
Disks : []* compute.AttachedDisk {
941
931
{
@@ -951,7 +941,7 @@ func TestDiskIsAttachedAndCompatible(t *testing.T) {
951
941
}
952
942
for _ , tc := range testCases {
953
943
t .Logf ("test case: %s" , tc .name )
954
- attached , err := diskIsAttachedAndCompatible (gce . ZonalCloudDisk ( tc .disk ) , tc .instance , nil , tc .mode )
944
+ attached , err := diskIsAttachedAndCompatible (tc .deviceName , tc .instance , nil , tc .mode )
955
945
if err != nil && ! tc .expErr {
956
946
t .Errorf ("Did not expect error but got: %v" , err )
957
947
}
0 commit comments