Browse Source

include license preview header when listing repos

Will Norris 11 years ago
parent
commit
7277108aa3
2 changed files with 9 additions and 0 deletions
  1. +6
    -0
      github/repos.go
  2. +3
    -0
      github/repos_test.go

+ 6
- 0
github/repos.go View File

@ -146,6 +146,9 @@ func (s *RepositoriesService) List(user string, opt *RepositoryListOptions) ([]R
return nil, nil, err
}
// TODO: remove custom Accept header when license support fully launches
req.Header.Set("Accept", mediaTypeLicensesPreview)
repos := new([]Repository)
resp, err := s.client.Do(req, repos)
if err != nil {
@ -180,6 +183,9 @@ func (s *RepositoriesService) ListByOrg(org string, opt *RepositoryListByOrgOpti
return nil, nil, err
}
// TODO: remove custom Accept header when license support fully launches
req.Header.Set("Accept", mediaTypeLicensesPreview)
repos := new([]Repository)
resp, err := s.client.Do(req, repos)
if err != nil {


+ 3
- 0
github/repos_test.go View File

@ -19,6 +19,7 @@ func TestRepositoriesService_List_authenticatedUser(t *testing.T) {
mux.HandleFunc("/user/repos", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", mediaTypeLicensesPreview)
fmt.Fprint(w, `[{"id":1},{"id":2}]`)
})
@ -39,6 +40,7 @@ func TestRepositoriesService_List_specifiedUser(t *testing.T) {
mux.HandleFunc("/users/u/repos", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", mediaTypeLicensesPreview)
testFormValues(t, r, values{
"type": "owner",
"sort": "created",
@ -71,6 +73,7 @@ func TestRepositoriesService_ListByOrg(t *testing.T) {
mux.HandleFunc("/orgs/o/repos", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testHeader(t, r, "Accept", mediaTypeLicensesPreview)
testFormValues(t, r, values{
"type": "forks",
"page": "2",


Loading…
Cancel
Save