From e76acfa55a696875a5bb9afcbf55cddb8fcea6ff Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Tue, 29 Nov 2022 09:42:58 -0500 Subject: [PATCH] Improve code coverage Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/github_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/github/github_test.go b/github/github_test.go index 42e3ce2ce93..53809399fac 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -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) { @@ -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, "")