@@ -78,39 +78,14 @@ func TestMachineLocalSSDDiskType(t *testing.T) {
7878
7979// TestInstanceNetworkInterfaceAliasIPRangesSpec tests the InstanceNetworkInterfaceAliasIPRangesSpec function
8080func TestInstanceNetworkInterfaceAliasIPRangesSpec (t * testing.T ) {
81- // Register the GCPMachine and GCPMachineList in a schema.
82- schema , err := infrav1 .SchemeBuilder .Register (& infrav1.GCPMachine {}, & infrav1.GCPMachineList {}).Build ()
83- assert .Nil (t , err )
84-
85- // Create a controller fake client.
86- testClient := fake .NewClientBuilder ().WithScheme (schema ).Build ()
87-
88- // Test machine parameter
89- failureDomain := "us-central1-a"
90- testMachine := clusterv1.Machine {
91- Spec : clusterv1.MachineSpec {
92- FailureDomain : & failureDomain ,
93- },
94- }
95-
9681 t .Run ("should return nil for empty alias IP ranges" , func (t * testing.T ) {
9782 testGCPMachine := infrav1.GCPMachine {
9883 Spec : infrav1.GCPMachineSpec {
9984 AliasIPRanges : []infrav1.AliasIPRange {},
10085 },
10186 }
10287
103- testScopeParams := MachineScopeParams {
104- Client : testClient ,
105- Machine : & testMachine ,
106- GCPMachine : & testGCPMachine ,
107- }
108-
109- testMachineScope , err := NewMachineScope (testScopeParams )
110- assert .Nil (t , err )
111- assert .NotNil (t , testMachineScope )
112-
113- result := testMachineScope .InstanceNetworkInterfaceAliasIPRangesSpec ()
88+ result := InstanceNetworkInterfaceAliasIPRangesSpec (testGCPMachine .Spec .AliasIPRanges )
11489 assert .Nil (t , result )
11590 })
11691
@@ -126,17 +101,7 @@ func TestInstanceNetworkInterfaceAliasIPRangesSpec(t *testing.T) {
126101 },
127102 }
128103
129- testScopeParams := MachineScopeParams {
130- Client : testClient ,
131- Machine : & testMachine ,
132- GCPMachine : & testGCPMachine ,
133- }
134-
135- testMachineScope , err := NewMachineScope (testScopeParams )
136- assert .Nil (t , err )
137- assert .NotNil (t , testMachineScope )
138-
139- result := testMachineScope .InstanceNetworkInterfaceAliasIPRangesSpec ()
104+ result := InstanceNetworkInterfaceAliasIPRangesSpec (testGCPMachine .Spec .AliasIPRanges )
140105 assert .NotNil (t , result )
141106 assert .Len (t , result , 1 )
142107 assert .Equal (t , "10.0.0.0/24" , result [0 ].IpCidrRange )
@@ -159,17 +124,7 @@ func TestInstanceNetworkInterfaceAliasIPRangesSpec(t *testing.T) {
159124 },
160125 }
161126
162- testScopeParams := MachineScopeParams {
163- Client : testClient ,
164- Machine : & testMachine ,
165- GCPMachine : & testGCPMachine ,
166- }
167-
168- testMachineScope , err := NewMachineScope (testScopeParams )
169- assert .Nil (t , err )
170- assert .NotNil (t , testMachineScope )
171-
172- result := testMachineScope .InstanceNetworkInterfaceAliasIPRangesSpec ()
127+ result := InstanceNetworkInterfaceAliasIPRangesSpec (testGCPMachine .Spec .AliasIPRanges )
173128 assert .NotNil (t , result )
174129 assert .Len (t , result , 2 )
175130 assert .Equal (t , "10.0.0.0/24" , result [0 ].IpCidrRange )
@@ -190,17 +145,7 @@ func TestInstanceNetworkInterfaceAliasIPRangesSpec(t *testing.T) {
190145 },
191146 }
192147
193- testScopeParams := MachineScopeParams {
194- Client : testClient ,
195- Machine : & testMachine ,
196- GCPMachine : & testGCPMachine ,
197- }
198-
199- testMachineScope , err := NewMachineScope (testScopeParams )
200- assert .Nil (t , err )
201- assert .NotNil (t , testMachineScope )
202-
203- result := testMachineScope .InstanceNetworkInterfaceAliasIPRangesSpec ()
148+ result := InstanceNetworkInterfaceAliasIPRangesSpec (testGCPMachine .Spec .AliasIPRanges )
204149 assert .NotNil (t , result )
205150 assert .Len (t , result , 1 )
206151 assert .Equal (t , "10.100.0.0/24" , result [0 ].IpCidrRange )
0 commit comments