Skip to content

Commit

Permalink
Improve code coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
  • Loading branch information
gmlewis committed Nov 29, 2022
1 parent 3cd13ca commit e76acfa
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,17 @@ func TestNewFormRequest(t *testing.T) {
if got, want := req.Header.Get("User-Agent"), c.UserAgent; got != want {
t.Errorf("NewFormRequest() User-Agent is %v, want %v", got, want)
}

apiVersion := req.Header.Get(headerAPIVersion)
if got, want := apiVersion, defaultAPIVersion; got != want {
t.Errorf("NewRequest() %v header is %v, want %v", headerAPIVersion, got, want)
}

req, _ = c.NewFormRequest(inURL, inBody, WithVersion("2022-11-29"))
apiVersion = req.Header.Get(headerAPIVersion)
if got, want := apiVersion, "2022-11-29"; got != want {
t.Errorf("NewRequest() %v header is %v, want %v", headerAPIVersion, got, want)
}
}

func TestNewFormRequest_badURL(t *testing.T) {
Expand Down Expand Up @@ -691,6 +702,22 @@ func TestNewFormRequest_errorForNoTrailingSlash(t *testing.T) {
}
}

func TestNewUploadRequest_WithVersion(t *testing.T) {
c := NewClient(nil)
req, _ := c.NewUploadRequest("https://example.com/", nil, 0, "")

apiVersion := req.Header.Get(headerAPIVersion)
if got, want := apiVersion, defaultAPIVersion; got != want {
t.Errorf("NewRequest() %v header is %v, want %v", headerAPIVersion, got, want)
}

req, _ = c.NewUploadRequest("https://example.com/", nil, 0, "", WithVersion("2022-11-29"))
apiVersion = req.Header.Get(headerAPIVersion)
if got, want := apiVersion, "2022-11-29"; got != want {
t.Errorf("NewRequest() %v header is %v, want %v", headerAPIVersion, got, want)
}
}

func TestNewUploadRequest_badURL(t *testing.T) {
c := NewClient(nil)
_, err := c.NewUploadRequest(":", nil, 0, "")
Expand Down

0 comments on commit e76acfa

Please sign in to comment.