@@ -3,6 +3,7 @@ package incidentio
33import (
44 "context"
55 "encoding/json"
6+ "errors"
67 "fmt"
78 "net/http"
89 "net/http/httptest"
@@ -14,7 +15,7 @@ import (
1415
1516// Test helpers
1617
17- func setup () (client * Client , mux * http.ServeMux , serverURL string , teardown func ()) {
18+ func setup () (client * Client , mux * http.ServeMux , serverURL string , teardown func ()) { //nolint: unparam
1819 mux = http .NewServeMux ()
1920 server := httptest .NewServer (mux )
2021
@@ -76,7 +77,7 @@ func TestIncidentsService_List(t *testing.T) {
7677 ]
7778 }`
7879
79- fmt .Fprint (w , response )
80+ _ , _ = fmt .Fprint (w , response )
8081 })
8182
8283 ctx := context .Background ()
@@ -144,7 +145,7 @@ func TestIncidentsService_Get(t *testing.T) {
144145 }
145146 }`
146147
147- fmt .Fprint (w , response )
148+ _ , _ = fmt .Fprint (w , response )
148149 })
149150
150151 ctx := context .Background ()
@@ -251,7 +252,7 @@ func TestIncidentsService_Create(t *testing.T) {
251252 }`
252253
253254 w .WriteHeader (http .StatusCreated )
254- fmt .Fprint (w , response )
255+ _ , _ = fmt .Fprint (w , response )
255256 })
256257
257258 ctx := context .Background ()
@@ -315,7 +316,7 @@ func TestIncidentsService_Update(t *testing.T) {
315316 }
316317 }`
317318
318- fmt .Fprint (w , response )
319+ _ , _ = fmt .Fprint (w , response )
319320 })
320321
321322 ctx := context .Background ()
@@ -363,7 +364,7 @@ func TestIncidentsService_ErrorHandling(t *testing.T) {
363364 client , mux , _ , teardown := setup ()
364365 defer teardown ()
365366
366- mux .HandleFunc ("/v2/incidents/not-found" , func (w http.ResponseWriter , r * http.Request ) {
367+ mux .HandleFunc ("/v2/incidents/not-found" , func (w http.ResponseWriter , _ * http.Request ) {
367368 w .WriteHeader (http .StatusNotFound )
368369 response := `{
369370 "type": "validation_error",
@@ -379,7 +380,7 @@ func TestIncidentsService_ErrorHandling(t *testing.T) {
379380 }
380381 ]
381382 }`
382- fmt .Fprint (w , response )
383+ _ , _ = fmt .Fprint (w , response )
383384 })
384385
385386 ctx := context .Background ()
@@ -389,7 +390,8 @@ func TestIncidentsService_ErrorHandling(t *testing.T) {
389390 t .Error ("Expected error, got nil" )
390391 }
391392
392- errResp , ok := err .(* ErrorResponse )
393+ errResp := & ErrorResponse {}
394+ ok := errors .As (err , & errResp )
393395 if ! ok {
394396 t .Errorf ("Error type = %T, want *ErrorResponse" , err )
395397 }
@@ -467,18 +469,18 @@ func TestTimestamp_UnmarshalJSON(t *testing.T) {
467469 t .Errorf ("Timestamp.UnmarshalJSON() error = %v, wantErr %v" , err , tt .wantErr )
468470 return
469471 }
470- if ! tt .wantErr && ! ts .Time . Equal (tt .want ) {
472+ if ! tt .wantErr && ! ts .Equal (tt .want ) {
471473 t .Errorf ("Timestamp.UnmarshalJSON() = %v, want %v" , ts .Time , tt .want )
472474 }
473475 })
474476 }
475477}
476478
477479func TestErrorResponse_Error (t * testing.T ) {
478- req , _ := http .NewRequest ("GET" , "https://api.incident.io/v2/incidents/123" , nil )
480+ req , _ := http .NewRequest (http . MethodGet , "https://api.incident.io/v2/incidents/123" , nil )
479481 resp := & http.Response {
480482 Request : req ,
481- StatusCode : 404 ,
483+ StatusCode : http . StatusNotFound ,
482484 }
483485
484486 err := & ErrorResponse {
0 commit comments