Skip to content

Commit

Permalink
Revert "Remove preview media type for Team Review Requests (#844)"
Browse files Browse the repository at this point in the history
This reverts commit b165831.
  • Loading branch information
gmlewis committed Feb 24, 2018
1 parent b165831 commit 9d80c9e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions github/github.go
Expand Up @@ -99,6 +99,9 @@ const (
// https://developer.github.com/changes/2017-07-17-update-topics-on-repositories/
mediaTypeTopicsPreview = "application/vnd.github.mercy-preview+json"

// https://developer.github.com/changes/2017-07-26-team-review-request-thor-preview/
mediaTypeTeamReviewPreview = "application/vnd.github.thor-preview+json"

// https://developer.github.com/v3/apps/marketplace/
mediaTypeMarketplacePreview = "application/vnd.github.valkyrie-preview+json"

Expand Down
9 changes: 9 additions & 0 deletions github/pulls_reviewers.go
Expand Up @@ -32,6 +32,9 @@ func (s *PullRequestsService) RequestReviewers(ctx context.Context, owner, repo
return nil, nil, err
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeTeamReviewPreview)

r := new(PullRequest)
resp, err := s.client.Do(ctx, req, r)
if err != nil {
Expand All @@ -56,6 +59,9 @@ func (s *PullRequestsService) ListReviewers(ctx context.Context, owner, repo str
return nil, nil, err
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeTeamReviewPreview)

reviewers := new(Reviewers)
resp, err := s.client.Do(ctx, req, reviewers)
if err != nil {
Expand All @@ -75,5 +81,8 @@ func (s *PullRequestsService) RemoveReviewers(ctx context.Context, owner, repo s
return nil, err
}

// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeTeamReviewPreview)

return s.client.Do(ctx, req, nil)
}
3 changes: 3 additions & 0 deletions github/pulls_reviewers_test.go
Expand Up @@ -20,6 +20,7 @@ func TestRequestReviewers(t *testing.T) {
mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
testBody(t, r, `{"reviewers":["octocat","googlebot"],"team_reviewers":["justice-league","injustice-league"]}`+"\n")
testHeader(t, r, "Accept", mediaTypeTeamReviewPreview)
fmt.Fprint(w, `{"number":1}`)
})

Expand All @@ -40,6 +41,7 @@ func TestRemoveReviewers(t *testing.T) {

mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
testHeader(t, r, "Accept", mediaTypeTeamReviewPreview)
testBody(t, r, `{"reviewers":["octocat","googlebot"],"team_reviewers":["justice-league"]}`+"\n")
})

Expand All @@ -55,6 +57,7 @@ func TestListReviewers(t *testing.T) {

mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", mediaTypeTeamReviewPreview)
fmt.Fprint(w, `{"users":[{"login":"octocat","id":1}],"teams":[{"id":1,"name":"Justice League"}]}`)
})

Expand Down

0 comments on commit 9d80c9e

Please sign in to comment.