Skip to content

Commit 860a976

Browse files
authored
test: use field getters rather than dereferencing pointers (#2354)
1 parent 757e493 commit 860a976

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

system_test.go

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,11 @@ func TestPullRequestSystem(t *testing.T) {
249249
}
250250
for _, pullRequest := range foundPullRequests {
251251
// Look for the PR we created
252-
if pullRequest.Number != nil && *pullRequest.Number == createdPullRequest.Number {
252+
if pullRequest.GetNumber() == createdPullRequest.Number {
253253
found = true
254254

255255
// Expect that we found a comment
256-
if pullRequest.Comments == nil {
257-
t.Fatal("pull request comments not set")
258-
}
259-
if *pullRequest.Comments == 0 {
256+
if pullRequest.GetComments() == 0 {
260257
t.Fatalf("Expected to have created a comment on the pull request.")
261258
}
262259
break
@@ -284,16 +281,10 @@ func TestPullRequestSystem(t *testing.T) {
284281
if err != nil {
285282
t.Fatalf("unexpected error in GetPullRequest() %s", err)
286283
}
287-
if foundPullRequest.Number == nil {
288-
t.Fatal("pull request number not set")
289-
}
290-
if diff := cmp.Diff(*foundPullRequest.Number, createdPullRequest.Number); diff != "" {
284+
if diff := cmp.Diff(foundPullRequest.GetNumber(), createdPullRequest.Number); diff != "" {
291285
t.Fatalf("pull request number mismatch (-want + got):\n%s", diff)
292286
}
293-
if foundPullRequest.State == nil {
294-
t.Fatal("pull request state not set")
295-
}
296-
if diff := cmp.Diff(*foundPullRequest.State, "closed"); diff != "" {
287+
if diff := cmp.Diff(foundPullRequest.GetState(), "closed"); diff != "" {
297288
t.Fatalf("pull request state mismatch (-want + got):\n%s", diff)
298289
}
299290
}
@@ -350,8 +341,9 @@ func TestFindMergedPullRequest(t *testing.T) {
350341
} else {
351342
found := false
352343
for _, pr := range prs {
353-
t.Logf("Found PR %d", *pr.Number)
354-
if pr.Number != nil && *pr.Number == test.want {
344+
pullNumber := pr.GetNumber()
345+
t.Logf("Found PR %d", pullNumber)
346+
if pr.Number != nil && pullNumber == test.want {
355347
found = true
356348
}
357349
}
@@ -442,10 +434,7 @@ func TestCreateRelease(t *testing.T) {
442434
if err != nil {
443435
t.Fatalf("unexpected error in CreateTag() %s", err)
444436
}
445-
if release.Body == nil {
446-
t.Fatalf("release body is not set")
447-
}
448-
if diff := cmp.Diff(*release.Body, body); diff != "" {
437+
if diff := cmp.Diff(release.GetBody(), body); diff != "" {
449438
t.Fatalf("release body mismatch (-want + got):\n%s", diff)
450439
}
451440
}

0 commit comments

Comments
 (0)