@@ -3,6 +3,7 @@ package linode
33import (
44 "context"
55 "errors"
6+ "net"
67 "net/http"
78 "strconv"
89 "testing"
@@ -135,12 +136,6 @@ func TestMetadataRetrieval(t *testing.T) {
135136 client .EXPECT ().ListInstances (gomock .Any (), filter ).Times (1 ).Return ([]linodego.Instance {
136137 {ID : id , Label : name },
137138 }, nil )
138- client .EXPECT ().GetInstanceIPAddresses (gomock .Any (), id ).Times (1 ).Return (& linodego.InstanceIPAddressResponse {
139- IPv4 : & linodego.InstanceIPv4Response {
140- Public : []* linodego.InstanceIP {},
141- Private : []* linodego.InstanceIP {},
142- },
143- }, nil )
144139
145140 meta , err := instances .InstanceMetadata (ctx , node )
146141 assert .Error (t , err , instanceNoIPAddressesError {id })
@@ -151,19 +146,13 @@ func TestMetadataRetrieval(t *testing.T) {
151146 id := 123
152147 name := "mock-instance"
153148 node := nodeWithName (name )
154- publicIPv4 := "45.76.101.25"
155- privateIPv4 := "192.168.133.65"
149+ publicIPv4 := net . ParseIP ( "45.76.101.25" )
150+ privateIPv4 := net . ParseIP ( "192.168.133.65" )
156151 linodeType := "g6-standard-1"
157152 region := "us-east"
158153 filter := linodeFilterListOptions (name )
159154 client .EXPECT ().ListInstances (gomock .Any (), filter ).Times (1 ).Return ([]linodego.Instance {
160- {ID : id , Label : name , Type : linodeType , Region : region },
161- }, nil )
162- client .EXPECT ().GetInstanceIPAddresses (gomock .Any (), id ).Times (1 ).Return (& linodego.InstanceIPAddressResponse {
163- IPv4 : & linodego.InstanceIPv4Response {
164- Public : []* linodego.InstanceIP {{Address : publicIPv4 }},
165- Private : []* linodego.InstanceIP {{Address : privateIPv4 }},
166- },
155+ {ID : id , Label : name , Type : linodeType , Region : region , IPv4 : []* net.IP {& publicIPv4 , & privateIPv4 }},
167156 }, nil )
168157
169158 meta , err := instances .InstanceMetadata (ctx , node )
@@ -177,11 +166,11 @@ func TestMetadataRetrieval(t *testing.T) {
177166 },
178167 {
179168 Type : v1 .NodeExternalIP ,
180- Address : publicIPv4 ,
169+ Address : publicIPv4 . String () ,
181170 },
182171 {
183172 Type : v1 .NodeInternalIP ,
184- Address : privateIPv4 ,
173+ Address : privateIPv4 . String () ,
185174 },
186175 })
187176 })
@@ -191,18 +180,12 @@ func TestMetadataRetrieval(t *testing.T) {
191180 name := "my-instance"
192181 providerID := providerIDPrefix + strconv .Itoa (id )
193182 node := nodeWithProviderID (providerID )
194- publicIPv4 := "32.74.121.25"
195- privateIPv4 := "192.168.121.42"
183+ publicIPv4 := net . ParseIP ( "32.74.121.25" )
184+ privateIPv4 := net . ParseIP ( "192.168.121.42" )
196185 linodeType := "g6-standard-1"
197186 region := "us-east"
198187 client .EXPECT ().GetInstance (gomock .Any (), id ).Times (1 ).Return (& linodego.Instance {
199- ID : id , Label : name , Type : linodeType , Region : region ,
200- }, nil )
201- client .EXPECT ().GetInstanceIPAddresses (gomock .Any (), id ).Times (1 ).Return (& linodego.InstanceIPAddressResponse {
202- IPv4 : & linodego.InstanceIPv4Response {
203- Public : []* linodego.InstanceIP {{Address : publicIPv4 }},
204- Private : []* linodego.InstanceIP {{Address : privateIPv4 }},
205- },
188+ ID : id , Label : name , Type : linodeType , Region : region , IPv4 : []* net.IP {& publicIPv4 , & privateIPv4 },
206189 }, nil )
207190
208191 meta , err := instances .InstanceMetadata (ctx , node )
@@ -217,11 +200,11 @@ func TestMetadataRetrieval(t *testing.T) {
217200 },
218201 {
219202 Type : v1 .NodeExternalIP ,
220- Address : publicIPv4 ,
203+ Address : publicIPv4 . String () ,
221204 },
222205 {
223206 Type : v1 .NodeInternalIP ,
224- Address : privateIPv4 ,
207+ Address : privateIPv4 . String () ,
225208 },
226209 })
227210 })
0 commit comments