Skip to content

Commit ed5a8f3

Browse files
authored
Apps.ListRepos/Apps.ListUserRepos: Add mercy-preview + nebula-preview headers (google#1806)
1 parent 0ef5f90 commit ed5a8f3

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

github/apps_installation.go

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package github
88
import (
99
"context"
1010
"fmt"
11+
"strings"
1112
)
1213

1314
// ListRepositories represents the response from the list repos endpoints.
@@ -30,6 +31,10 @@ func (s *AppsService) ListRepos(ctx context.Context, opts *ListOptions) (*ListRe
3031
return nil, nil, err
3132
}
3233

34+
// TODO: remove custom Accept headers when APIs fully launch.
35+
acceptHeaders := []string{mediaTypeTopicsPreview, mediaTypeRepositoryVisibilityPreview}
36+
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))
37+
3338
var r *ListRepositories
3439

3540
resp, err := s.client.Do(ctx, req, &r)
@@ -56,6 +61,10 @@ func (s *AppsService) ListUserRepos(ctx context.Context, id int64, opts *ListOpt
5661
return nil, nil, err
5762
}
5863

64+
// TODO: remove custom Accept headers when APIs fully launch.
65+
acceptHeaders := []string{mediaTypeTopicsPreview, mediaTypeRepositoryVisibilityPreview}
66+
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))
67+
5968
var r *ListRepositories
6069
resp, err := s.client.Do(ctx, req, &r)
6170
if err != nil {

github/apps_installation_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@ import (
1010
"fmt"
1111
"net/http"
1212
"reflect"
13+
"strings"
1314
"testing"
1415
)
1516

1617
func TestAppsService_ListRepos(t *testing.T) {
1718
client, mux, _, teardown := setup()
1819
defer teardown()
1920

21+
wantAcceptHeaders := []string{mediaTypeTopicsPreview, mediaTypeRepositoryVisibilityPreview}
2022
mux.HandleFunc("/installation/repositories", func(w http.ResponseWriter, r *http.Request) {
2123
testMethod(t, r, "GET")
24+
testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", "))
2225
testFormValues(t, r, values{
2326
"page": "1",
2427
"per_page": "2",
@@ -52,8 +55,10 @@ func TestAppsService_ListUserRepos(t *testing.T) {
5255
client, mux, _, teardown := setup()
5356
defer teardown()
5457

58+
wantAcceptHeaders := []string{mediaTypeTopicsPreview, mediaTypeRepositoryVisibilityPreview}
5559
mux.HandleFunc("/user/installations/1/repositories", func(w http.ResponseWriter, r *http.Request) {
5660
testMethod(t, r, "GET")
61+
testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", "))
5762
testFormValues(t, r, values{
5863
"page": "1",
5964
"per_page": "2",

0 commit comments

Comments
 (0)