@@ -103,17 +103,17 @@ func TestInvalidVMUniqueID(t *testing.T) {
103103
104104func TestGetNCVersions (t * testing.T ) {
105105 networkMetadata := []byte (`{
106- "interface": [
107- {
108- "interfaceCompartmentVersion": "1",
109- "interfaceCompartmentId ": "nc-12345-67890"
110- },
111- {
112- "interfaceCompartmentVersion": "1",
113- "interfaceCompartmentId ": ""
114- }
115- ]
116- }` )
106+ "interface": [
107+ {
108+ "interfaceCompartmentVersion": "1",
109+ "interfaceCompartmentID ": "nc-12345-67890"
110+ },
111+ {
112+ "interfaceCompartmentVersion": "1",
113+ "interfaceCompartmentID ": ""
114+ }
115+ ]
116+ }` )
117117
118118 mockIMDSServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
119119 // request header "Metadata: true" must be present
@@ -131,7 +131,10 @@ func TestGetNCVersions(t *testing.T) {
131131
132132 w .WriteHeader (http .StatusOK )
133133 _ , writeErr := w .Write (networkMetadata )
134- require .NoError (t , writeErr , "error writing response" )
134+ if writeErr != nil {
135+ t .Errorf ("error writing response: %v" , writeErr )
136+ return
137+ }
135138 }))
136139 defer mockIMDSServer .Close ()
137140
@@ -143,11 +146,11 @@ func TestGetNCVersions(t *testing.T) {
143146 require .Len (t , interfaces , 2 , "expected 2 interfaces" )
144147
145148 // Check first interface
146- assert .Equal (t , "nc-12345-67890" , interfaces [0 ].InterfaceCompartmentId )
149+ assert .Equal (t , "nc-12345-67890" , interfaces [0 ].InterfaceCompartmentID )
147150 assert .Equal (t , "1" , interfaces [0 ].InterfaceCompartmentVersion )
148151
149152 // Check second interface
150- assert .Equal (t , "" , interfaces [1 ].InterfaceCompartmentId )
153+ assert .Equal (t , "" , interfaces [1 ].InterfaceCompartmentID )
151154 assert .Equal (t , "1" , interfaces [1 ].InterfaceCompartmentVersion )
152155}
153156
@@ -158,10 +161,13 @@ func TestGetNCVersionsInvalidEndpoint(t *testing.T) {
158161}
159162
160163func TestGetNCVersionsInvalidJSON (t * testing.T ) {
161- mockIMDSServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
164+ mockIMDSServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , _ * http.Request ) {
162165 w .WriteHeader (http .StatusOK )
163166 _ , err := w .Write ([]byte ("not json" ))
164- require .NoError (t , err )
167+ if err != nil {
168+ t .Errorf ("error writing response: %v" , err )
169+ return
170+ }
165171 }))
166172 defer mockIMDSServer .Close ()
167173
@@ -172,27 +178,30 @@ func TestGetNCVersionsInvalidJSON(t *testing.T) {
172178
173179func TestGetNCVersionsNoNCIDs (t * testing.T ) {
174180 networkMetadataNoNC := []byte (`{
175- "interface": [
176- {
177- "ipv4": {
178- "ipAddress": [
179- {
180- "privateIpAddress": "10.0.0.4",
181- "publicIpAddress": ""
182- }
183- ]
184- }
185- }
186- ]
187- }` )
181+ "interface": [
182+ {
183+ "ipv4": {
184+ "ipAddress": [
185+ {
186+ "privateIpAddress": "10.0.0.4",
187+ "publicIpAddress": ""
188+ }
189+ ]
190+ }
191+ }
192+ ]
193+ }` )
188194
189195 mockIMDSServer := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
190196 metadataHeader := r .Header .Get ("Metadata" )
191197 assert .Equal (t , "true" , metadataHeader )
192198
193199 w .WriteHeader (http .StatusOK )
194200 _ , writeErr := w .Write (networkMetadataNoNC )
195- require .NoError (t , writeErr , "error writing response" )
201+ if writeErr != nil {
202+ t .Errorf ("error writing response: %v" , writeErr )
203+ return
204+ }
196205 }))
197206 defer mockIMDSServer .Close ()
198207
@@ -202,5 +211,7 @@ func TestGetNCVersionsNoNCIDs(t *testing.T) {
202211
203212 // Verify we got interfaces but they don't have compartment IDs
204213 require .Len (t , interfaces , 1 , "expected 1 interface" )
205- assert .Equal (t , "" , interfaces [0 ].InterfaceCompartmentId )
214+
215+ // Check that interfaces don't have compartment IDs
216+ assert .Equal (t , "" , interfaces [0 ].InterfaceCompartmentID )
206217}
0 commit comments