Skip to content

Commit

Permalink
chore: fix golang-lint issues
Browse files Browse the repository at this point in the history
Signed-off-by: Rui Chen <rui@chenrui.dev>
  • Loading branch information
chenrui333 authored and wlynch committed Jan 11, 2025
1 parent df52b44 commit 989f32e
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ func TestRefreshTokenWithParameters(t *testing.T) {
installationTokenOptions := &github.InstallationTokenOptions{
RepositoryIDs: []int64{1234},
Permissions: &github.InstallationPermissions{
Contents: github.String("write"),
Issues: github.String("read"),
Contents: github.Ptr("write"),
Issues: github.Ptr("read"),
},
}

Expand All @@ -219,14 +219,15 @@ func TestRefreshTokenWithParameters(t *testing.T) {
// Convert io.ReadWriter to String without deleting body data.
wantBody, _ := GetReadWriter(installationTokenOptions)
wantBodyBytes := new(bytes.Buffer)
wantBodyBytes.ReadFrom(wantBody)
if _, err := wantBodyBytes.ReadFrom(wantBody); err != nil {
t.Fatalf("error reading from wantBody: %v", err)
}
wantBodyString := wantBodyBytes.String()

roundTripper := RoundTrip{
rt: func(req *http.Request) (*http.Response, error) {
// Convert io.ReadCloser to String without deleting body data.
var gotBodyBytes []byte
gotBodyBytes, _ = io.ReadAll(req.Body)
gotBodyBytes, _ := io.ReadAll(req.Body)
req.Body = io.NopCloser(bytes.NewBuffer(gotBodyBytes))
gotBodyString := string(gotBodyBytes)

Expand All @@ -240,11 +241,11 @@ func TestRefreshTokenWithParameters(t *testing.T) {
Token: "token_string",
ExpiresAt: time.Now(),
Repositories: []github.Repository{{
ID: github.Int64(1234),
ID: github.Ptr(int64(1234)),
}},
Permissions: github.InstallationPermissions{
Contents: github.String("write"),
Issues: github.String("read"),
Contents: github.Ptr("write"),
Issues: github.Ptr("read"),
},
}
tokenReadWriter, err := GetReadWriter(accessToken)
Expand All @@ -265,7 +266,9 @@ func TestRefreshTokenWithParameters(t *testing.T) {
}
tr.InstallationTokenOptions = installationTokenOptions

req, err := http.NewRequest("POST", fmt.Sprintf("%s/app/installations/%v/access_tokens", tr.BaseURL, tr.installationID), body)
req, err := http.NewRequest("POST",
fmt.Sprintf("%s/app/installations/%v/access_tokens", tr.BaseURL, tr.installationID),
body)
if err != nil {
t.Fatal("unexpected error:", err)
}
Expand All @@ -278,8 +281,8 @@ func TestRefreshTokenWithTrailingSlashBaseURL(t *testing.T) {
installationTokenOptions := &github.InstallationTokenOptions{
RepositoryIDs: []int64{1234},
Permissions: &github.InstallationPermissions{
Contents: github.String("write"),
Issues: github.String("read"),
Contents: github.Ptr("write"),
Issues: github.Ptr("read"),
},
}

Expand All @@ -288,7 +291,9 @@ func TestRefreshTokenWithTrailingSlashBaseURL(t *testing.T) {
// Convert io.ReadWriter to String without deleting body data.
wantBody, _ := GetReadWriter(installationTokenOptions)
wantBodyBytes := new(bytes.Buffer)
wantBodyBytes.ReadFrom(wantBody)
if _, err := wantBodyBytes.ReadFrom(wantBody); err != nil {
t.Fatalf("error reading from wantBody: %v", err)
}
wantBodyString := wantBodyBytes.String()

roundTripper := RoundTrip{
Expand All @@ -308,8 +313,7 @@ func TestRefreshTokenWithTrailingSlashBaseURL(t *testing.T) {
}

// Convert io.ReadCloser to String without deleting body data.
var gotBodyBytes []byte
gotBodyBytes, _ = io.ReadAll(req.Body)
gotBodyBytes, _ := io.ReadAll(req.Body)
req.Body = io.NopCloser(bytes.NewBuffer(gotBodyBytes))
gotBodyString := string(gotBodyBytes)

Expand All @@ -323,11 +327,11 @@ func TestRefreshTokenWithTrailingSlashBaseURL(t *testing.T) {
Token: tokenToBe,
ExpiresAt: time.Now(),
Repositories: []github.Repository{{
ID: github.Int64(1234),
ID: github.Ptr(int64(1234)),
}},
Permissions: github.InstallationPermissions{
Contents: github.String("write"),
Issues: github.String("read"),
Contents: github.Ptr("write"),
Issues: github.Ptr("read"),
},
}
tokenReadWriter, err := GetReadWriter(accessToken)
Expand Down

0 comments on commit 989f32e

Please sign in to comment.