Skip to content

Commit b66ae39

Browse files
committed
Handle errors from JSON encoding and response writing
Added error ignoring for json.NewEncoder(w).Encode and w.Write calls in test helpers to prevent unhandled errors during test execution.
1 parent f6ddbd7 commit b66ae39

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

github_server_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func withRequestMatch(endpoint string, response any) mockOption {
2525
return func(m *mockedHTTPClient) {
2626
m.handlers[endpoint] = func(w http.ResponseWriter, _ *http.Request) {
2727
w.Header().Set("Content-Type", "application/json")
28-
json.NewEncoder(w).Encode(response)
28+
_ = json.NewEncoder(w).Encode(response)
2929
}
3030
}
3131
}
@@ -64,7 +64,7 @@ func newMockedHTTPClient(opts ...mockOption) (*http.Client, func()) {
6464
}
6565

6666
w.WriteHeader(http.StatusNotFound)
67-
w.Write([]byte(`{"message":"Not Found"}`))
67+
_, _ = w.Write([]byte(`{"message":"Not Found"}`))
6868
}))
6969

7070
client := &http.Client{

0 commit comments

Comments
 (0)