Skip to content

Commit 003d736

Browse files
committed
fix: resolve linter errors in github_test.go
- Explicitly ignore error returns from json.Encoder.Encode() with _ - Explicitly ignore error returns from w.Write() with _, _ - Change t.Error to t.Fatal for nil pointer checks to prevent SA5011 warnings - All tests passing with no linter errors
1 parent 35f5ef2 commit 003d736

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

github_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func Test_githubClient_createInstallationToken_ErrorCases(t *testing.T) {
5757
setupServer: func() *httptest.Server {
5858
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
5959
w.WriteHeader(http.StatusCreated)
60-
json.NewEncoder(w).Encode(InstallationToken{
60+
_ = json.NewEncoder(w).Encode(InstallationToken{
6161
Token: "test-token",
6262
ExpiresAt: time.Now().Add(1 * time.Hour),
6363
})
@@ -73,7 +73,7 @@ func Test_githubClient_createInstallationToken_ErrorCases(t *testing.T) {
7373
setupServer: func() *httptest.Server {
7474
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
7575
w.WriteHeader(http.StatusBadRequest)
76-
w.Write([]byte(`{"message":"Bad Request"}`))
76+
_, _ = w.Write([]byte(`{"message":"Bad Request"}`))
7777
}))
7878
},
7979
opts: nil,
@@ -85,7 +85,7 @@ func Test_githubClient_createInstallationToken_ErrorCases(t *testing.T) {
8585
setupServer: func() *httptest.Server {
8686
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
8787
w.WriteHeader(http.StatusUnauthorized)
88-
w.Write([]byte(`{"message":"Unauthorized"}`))
88+
_, _ = w.Write([]byte(`{"message":"Unauthorized"}`))
8989
}))
9090
},
9191
opts: nil,
@@ -97,7 +97,7 @@ func Test_githubClient_createInstallationToken_ErrorCases(t *testing.T) {
9797
setupServer: func() *httptest.Server {
9898
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
9999
w.WriteHeader(http.StatusForbidden)
100-
w.Write([]byte(`{"message":"Forbidden"}`))
100+
_, _ = w.Write([]byte(`{"message":"Forbidden"}`))
101101
}))
102102
},
103103
opts: nil,
@@ -109,7 +109,7 @@ func Test_githubClient_createInstallationToken_ErrorCases(t *testing.T) {
109109
setupServer: func() *httptest.Server {
110110
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
111111
w.WriteHeader(http.StatusNotFound)
112-
w.Write([]byte(`{"message":"Not Found"}`))
112+
_, _ = w.Write([]byte(`{"message":"Not Found"}`))
113113
}))
114114
},
115115
opts: nil,
@@ -121,7 +121,7 @@ func Test_githubClient_createInstallationToken_ErrorCases(t *testing.T) {
121121
setupServer: func() *httptest.Server {
122122
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
123123
w.WriteHeader(http.StatusCreated)
124-
w.Write([]byte(`{invalid json`))
124+
_, _ = w.Write([]byte(`{invalid json`))
125125
}))
126126
},
127127
opts: nil,
@@ -133,7 +133,7 @@ func Test_githubClient_createInstallationToken_ErrorCases(t *testing.T) {
133133
setupServer: func() *httptest.Server {
134134
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
135135
w.WriteHeader(http.StatusCreated)
136-
json.NewEncoder(w).Encode(InstallationToken{
136+
_ = json.NewEncoder(w).Encode(InstallationToken{
137137
Token: "test-token",
138138
ExpiresAt: time.Now().Add(1 * time.Hour),
139139
})
@@ -147,7 +147,7 @@ func Test_githubClient_createInstallationToken_ErrorCases(t *testing.T) {
147147
setupServer: func() *httptest.Server {
148148
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
149149
w.WriteHeader(http.StatusOK)
150-
json.NewEncoder(w).Encode(InstallationToken{
150+
_ = json.NewEncoder(w).Encode(InstallationToken{
151151
Token: "test-token",
152152
ExpiresAt: time.Now().Add(1 * time.Hour),
153153
})
@@ -201,7 +201,7 @@ func Test_Ptr(t *testing.T) {
201201
s := "test"
202202
p := Ptr(s)
203203
if p == nil {
204-
t.Error("Ptr() returned nil")
204+
t.Fatal("Ptr() returned nil")
205205
}
206206
if *p != s {
207207
t.Errorf("Ptr() = %v, want %v", *p, s)
@@ -212,7 +212,7 @@ func Test_Ptr(t *testing.T) {
212212
i := 42
213213
p := Ptr(i)
214214
if p == nil {
215-
t.Error("Ptr() returned nil")
215+
t.Fatal("Ptr() returned nil")
216216
}
217217
if *p != i {
218218
t.Errorf("Ptr() = %v, want %v", *p, i)
@@ -223,7 +223,7 @@ func Test_Ptr(t *testing.T) {
223223
i := int64(123456)
224224
p := Ptr(i)
225225
if p == nil {
226-
t.Error("Ptr() returned nil")
226+
t.Fatal("Ptr() returned nil")
227227
}
228228
if *p != i {
229229
t.Errorf("Ptr() = %v, want %v", *p, i)
@@ -252,7 +252,7 @@ func Test_createInstallationToken_ErrorPaths(t *testing.T) {
252252
client := newGitHubClient(&http.Client{})
253253
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
254254
w.WriteHeader(http.StatusCreated)
255-
json.NewEncoder(w).Encode(InstallationToken{
255+
_ = json.NewEncoder(w).Encode(InstallationToken{
256256
Token: "test-token",
257257
ExpiresAt: time.Now().Add(1 * time.Hour),
258258
})

0 commit comments

Comments
 (0)