@@ -200,7 +200,7 @@ func TestNewHealthzHandlerWithChecks(t *testing.T) {
200200 healthHandler , err := NewHealthzHandlerWithChecks (tt .cnsConfig )
201201 require .NoError (t , err )
202202
203- healthHandler .ServeHTTP (responseRecorder , httptest .NewRequest ("GET" , "/healthz" , nil ))
203+ healthHandler .ServeHTTP (responseRecorder , httptest .NewRequest ("GET" , "/healthz" , http . NoBody ))
204204
205205 require .Equal (t , tt .expectedHealthy , responseRecorder .Code == http .StatusOK )
206206 })
@@ -250,7 +250,7 @@ users:
250250 return "" , fmt .Errorf ("failed to create temp kubeconfig file: %w" , err )
251251 }
252252
253- _ , err = kubeConfigFile .Write ([] byte ( tempKubeConfig ) )
253+ _ , err = kubeConfigFile .WriteString ( tempKubeConfig )
254254 if err != nil {
255255 return "" , fmt .Errorf ("failed to write kubeconfig to temp file: %w" , err )
256256 }
@@ -264,12 +264,18 @@ func setupMockAPIServer(code int) *httptest.Server {
264264 // Handle requests based on the path
265265 switch r .URL .Path {
266266 case "/apis/acn.azure.com/v1alpha" :
267- w .Write ([]byte (nncCRD ))
267+ _ , err := w .Write ([]byte (nncCRD ))
268+ if err != nil {
269+ http .Error (w , err .Error (), http .StatusInternalServerError )
270+ }
268271 case "/apis/acn.azure.com/v1alpha/namespaces/kube-system/nodenetworkconfigs" :
269272 if code == http .StatusOK {
270273 w .Header ().Set ("Cache-Control" , "no-cache, private" )
271274 w .Header ().Set ("Content-Type" , "application/json" )
272- w .Write ([]byte (nncResult ))
275+ _ , err := w .Write ([]byte (nncResult ))
276+ if err != nil {
277+ http .Error (w , err .Error (), http .StatusInternalServerError )
278+ }
273279 } else {
274280 w .WriteHeader (code )
275281 }
0 commit comments