Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,16 +572,13 @@ func TestNewRequest_invalidJSON(t *testing.T) {
c := NewClient(nil)

type T struct {
A map[any]any
F func()
}
_, err := c.NewRequest("GET", ".", &T{})

if err == nil {
t.Error("Expected error to be returned.")
}
if !errors.As(err, new(*json.UnsupportedTypeError)) {
t.Errorf("Expected a JSON error; got %#v.", err)
}
}

func TestNewRequest_badURL(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion github/repos_hooks_deliveries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"strings"
"testing"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -261,7 +262,7 @@ func TestHookDelivery_ParsePayload_invalidPayload(t *testing.T) {
}

_, err := d.ParseRequestPayload()
if err == nil || err.Error() != "json: cannot unmarshal string into Go struct field CheckRun.check_run.id of type int64" {
if err == nil || !strings.Contains(err.Error(), "json: cannot unmarshal") || !strings.Contains(err.Error(), "check_run.id") {
t.Errorf("unexpected error: %v", err)
}
}
Expand Down
4 changes: 2 additions & 2 deletions github/security_advisories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisoriesForOrg_Unmars
advisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisoriesForOrg(ctx, "o", nil)
if err == nil {
t.Error("Expected unmarshal error")
} else if !strings.Contains(err.Error(), "json: cannot unmarshal number into Go struct field SecurityAdvisory.ghsa_id of type string") {
} else if !strings.Contains(err.Error(), "json: cannot unmarshal") || !strings.Contains(err.Error(), "ghsa_id") {
t.Errorf("ListRepositorySecurityAdvisoriesForOrg returned unexpected error: %v", err)
}
if got, want := resp.Response.StatusCode, http.StatusOK; got != want {
Expand Down Expand Up @@ -721,7 +721,7 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisories_UnmarshalErr
advisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisories(ctx, "o", "r", nil)
if err == nil {
t.Error("Expected unmarshal error")
} else if !strings.Contains(err.Error(), "json: cannot unmarshal number into Go struct field SecurityAdvisory.ghsa_id of type string") {
} else if !strings.Contains(err.Error(), "json: cannot unmarshal") || !strings.Contains(err.Error(), "ghsa_id") {
t.Errorf("ListRepositorySecurityAdvisories returned unexpected error: %v", err)
}
if got, want := resp.Response.StatusCode, http.StatusOK; got != want {
Expand Down
Loading