Skip to content

Commit 3750bfc

Browse files
Fix lint
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io> Assisted by [OpenAI](https://platform.openai.com/) Assisted by [GitHub Copilot](https://github.com/features/copilot)
1 parent d3e3619 commit 3750bfc

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

cla-backend-go/github/github_repository_test.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ func TestGetCommentBodyOmitsCoAuthorRemovalGuidanceWhenNoCoAuthorIsMissing(t *te
6868
assert.NotContains(t, body, "Alternatively, if the co-author should not be included, remove the `Co-authored-by:` line from the commit message.")
6969
}
7070

71-
func newTestGithubClient(server *httptest.Server) *gh.Client {
71+
func newTestGithubClient(t *testing.T, server *httptest.Server) *gh.Client {
72+
t.Helper()
7273
client := gh.NewClient(server.Client())
73-
baseURL, _ := url.Parse(server.URL + "/")
74+
baseURL, err := url.Parse(server.URL + "/")
75+
assert.NoError(t, err)
7476
client.BaseURL = baseURL
7577
client.UploadURL = baseURL
7678
return client
@@ -84,10 +86,11 @@ func TestFetchComparePageRetriesThenSucceeds(t *testing.T) {
8486
w.Header().Set("Content-Type", "application/json")
8587
if attempts == 1 {
8688
w.WriteHeader(http.StatusBadGateway)
87-
_, _ = io.WriteString(w, `{"message":"bad gateway"}`)
89+
_, err := io.WriteString(w, `{"message":"bad gateway"}`)
90+
assert.NoError(t, err)
8891
return
8992
}
90-
_, _ = io.WriteString(w, `{
93+
_, err := io.WriteString(w, `{
9194
"commits": [{
9295
"sha": "abc123",
9396
"commit": {
@@ -105,10 +108,11 @@ func TestFetchComparePageRetriesThenSucceeds(t *testing.T) {
105108
}
106109
}]
107110
}`)
111+
assert.NoError(t, err)
108112
}))
109113
defer srv.Close()
110114

111-
client := newTestGithubClient(srv)
115+
client := newTestGithubClient(t, srv)
112116
commits, _, err := fetchComparePage(context.Background(), client, "o", "r", "base", "head", 1, 100, 7)
113117
assert.NoError(t, err)
114118
if assert.Len(t, commits, 1) {
@@ -132,11 +136,12 @@ func TestListPullRequestCommitsComparePreservesPageOrder(t *testing.T) {
132136

133137
switch r.URL.Path {
134138
case "/repos/o/r/pulls/7":
135-
_, _ = io.WriteString(w, `{
139+
_, err := io.WriteString(w, `{
136140
"number": 7,
137141
"base": { "sha": "base" },
138142
"head": { "sha": "head" }
139143
}`)
144+
assert.NoError(t, err)
140145
return
141146

142147
case "/repos/o/r/compare/base...head":
@@ -149,34 +154,37 @@ func TestListPullRequestCommitsComparePreservesPageOrder(t *testing.T) {
149154
serverURL, serverURL,
150155
),
151156
)
152-
_, _ = io.WriteString(w, `{
157+
_, err := io.WriteString(w, `{
153158
"commits": [{
154159
"sha": "sha1",
155160
"commit": { "message": "msg1", "author": { "name": "name1", "email": "e1@example.com" } },
156161
"author": { "id": 1, "login": "u1" }
157162
}]
158163
}`)
164+
assert.NoError(t, err)
159165
return
160166

161167
case "2":
162168
time.Sleep(50 * time.Millisecond)
163-
_, _ = io.WriteString(w, `{
169+
_, err := io.WriteString(w, `{
164170
"commits": [{
165171
"sha": "sha2",
166172
"commit": { "message": "msg2", "author": { "name": "name2", "email": "e2@example.com" } },
167173
"author": { "id": 2, "login": "u2" }
168174
}]
169175
}`)
176+
assert.NoError(t, err)
170177
return
171178

172179
case "3":
173-
_, _ = io.WriteString(w, `{
180+
_, err := io.WriteString(w, `{
174181
"commits": [{
175182
"sha": "sha3",
176183
"commit": { "message": "msg3", "author": { "name": "name3", "email": "e3@example.com" } },
177184
"author": { "id": 3, "login": "u3" }
178185
}]
179186
}`)
187+
assert.NoError(t, err)
180188
return
181189
}
182190
}
@@ -186,7 +194,7 @@ func TestListPullRequestCommitsComparePreservesPageOrder(t *testing.T) {
186194
defer srv.Close()
187195
serverURL = srv.URL
188196

189-
client := newTestGithubClient(srv)
197+
client := newTestGithubClient(t, srv)
190198
commits, err := ListPullRequestCommitsCompare(context.Background(), client, "o", "r", 7)
191199
assert.NoError(t, err)
192200
if assert.Len(t, commits, 3) {

0 commit comments

Comments
 (0)