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, "")