Skip to content

Commit

Permalink
Remove graduated custom media headers (google#1493)
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleimp authored Apr 19, 2020
1 parent 4cd0027 commit 4ca0dcc
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 20 deletions.
1 change: 0 additions & 1 deletion github/apps_installation.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ func (s *AppsService) RevokeInstallationToken(ctx context.Context) (*Response, e
if err != nil {
return nil, err
}
req.Header.Set("Accept", mediaTypeRevokeTokenPreview)

return s.client.Do(ctx, req, nil)
}
1 change: 0 additions & 1 deletion github/apps_installation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ func TestAppsService_RevokeInstallationToken(t *testing.T) {

mux.HandleFunc("/installation/token", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
testHeader(t, r, "Accept", mediaTypeRevokeTokenPreview)
w.WriteHeader(http.StatusNoContent)
})

Expand Down
6 changes: 0 additions & 6 deletions github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ const (

// Media Type values to access preview APIs

// https://developer.github.com/changes/2020-01-10-revoke-installation-token/
mediaTypeRevokeTokenPreview = "application/vnd.github.gambit-preview+json"

// https://developer.github.com/changes/2014-12-09-new-attributes-for-stars-api/
mediaTypeStarringPreview = "application/vnd.github.v3.star+json"

Expand Down Expand Up @@ -109,9 +106,6 @@ const (
// https://developer.github.com/changes/2018-12-18-interactions-preview/
mediaTypeInteractionRestrictionsPreview = "application/vnd.github.sombra-preview+json"

// https://developer.github.com/changes/2019-02-14-draft-pull-requests/
mediaTypeDraftPreview = "application/vnd.github.shadow-cat-preview+json"

// https://developer.github.com/changes/2019-03-14-enabling-disabling-pages/
mediaTypeEnablePagesAPIPreview = "application/vnd.github.switcheroo-preview+json"

Expand Down
10 changes: 3 additions & 7 deletions github/pulls.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (s *PullRequestsService) List(ctx context.Context, owner string, repo strin
}

// TODO: remove custom Accept header when this API fully launches.
acceptHeaders := []string{mediaTypeLockReasonPreview, mediaTypeDraftPreview}
acceptHeaders := []string{mediaTypeLockReasonPreview}
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))

var pulls []*PullRequest
Expand Down Expand Up @@ -179,7 +179,7 @@ func (s *PullRequestsService) ListPullRequestsWithCommit(ctx context.Context, ow
}

// TODO: remove custom Accept header when this API fully launches.
acceptHeaders := []string{mediaTypeListPullsOrBranchesForCommitPreview, mediaTypeDraftPreview, mediaTypeLockReasonPreview}
acceptHeaders := []string{mediaTypeListPullsOrBranchesForCommitPreview, mediaTypeLockReasonPreview}
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))
var pulls []*PullRequest
resp, err := s.client.Do(ctx, req, &pulls)
Expand All @@ -201,7 +201,7 @@ func (s *PullRequestsService) Get(ctx context.Context, owner string, repo string
}

// TODO: remove custom Accept header when this API fully launches.
acceptHeaders := []string{mediaTypeLockReasonPreview, mediaTypeDraftPreview}
acceptHeaders := []string{mediaTypeLockReasonPreview}
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))

pull := new(PullRequest)
Expand Down Expand Up @@ -262,10 +262,6 @@ func (s *PullRequestsService) Create(ctx context.Context, owner string, repo str
return nil, nil, err
}

// TODO: remove custom Accept header when this API fully launches.
acceptHeaders := []string{mediaTypeDraftPreview}
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))

p := new(PullRequest)
resp, err := s.client.Do(ctx, req, p)
if err != nil {
Expand Down
8 changes: 3 additions & 5 deletions github/pulls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestPullRequestsService_List(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

wantAcceptHeaders := []string{mediaTypeLockReasonPreview, mediaTypeDraftPreview}
wantAcceptHeaders := []string{mediaTypeLockReasonPreview}
mux.HandleFunc("/repos/o/r/pulls", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", "))
Expand Down Expand Up @@ -51,7 +51,7 @@ func TestPullRequestsService_ListPullRequestsWithCommit(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

wantAcceptHeaders := []string{mediaTypeListPullsOrBranchesForCommitPreview, mediaTypeDraftPreview, mediaTypeLockReasonPreview}
wantAcceptHeaders := []string{mediaTypeListPullsOrBranchesForCommitPreview, mediaTypeLockReasonPreview}
mux.HandleFunc("/repos/o/r/commits/sha/pulls", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", "))
Expand Down Expand Up @@ -90,7 +90,7 @@ func TestPullRequestsService_Get(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

wantAcceptHeaders := []string{mediaTypeLockReasonPreview, mediaTypeDraftPreview}
wantAcceptHeaders := []string{mediaTypeLockReasonPreview}
mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", "))
Expand Down Expand Up @@ -306,8 +306,6 @@ func TestPullRequestsService_Create(t *testing.T) {
json.NewDecoder(r.Body).Decode(v)

testMethod(t, r, "POST")
wantAcceptHeaders := []string{mediaTypeDraftPreview}
testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", "))
if !reflect.DeepEqual(v, input) {
t.Errorf("Request body = %+v, want %+v", v, input)
}
Expand Down

0 comments on commit 4ca0dcc

Please sign in to comment.