Browse Source

Fix GetBranch response

Closes #490.

Change-Id: Ie12aca585fe07cb572b347ef3b8f42c26b229808
isqua 9 years ago
committed by Glenn Lewis
parent
commit
a77ccc9a58
2 changed files with 12 additions and 7 deletions
  1. +3
    -3
      github/repos.go
  2. +9
    -4
      github/repos_test.go

+ 3
- 3
github/repos.go View File

@ -501,9 +501,9 @@ func (s *RepositoriesService) ListTags(owner string, repo string, opt *ListOptio
// Branch represents a repository branch // Branch represents a repository branch
type Branch struct { type Branch struct {
Name *string `json:"name,omitempty"`
Commit *Commit `json:"commit,omitempty"`
Protected *bool `json:"protected,omitempty"`
Name *string `json:"name,omitempty"`
Commit *RepositoryCommit `json:"commit,omitempty"`
Protected *bool `json:"protected,omitempty"`
} }
// Protection represents a repository branch's protection. // Protection represents a repository branch's protection.


+ 9
- 4
github/repos_test.go View File

@ -434,7 +434,7 @@ func TestRepositoriesService_ListBranches(t *testing.T) {
t.Errorf("Repositories.ListBranches returned error: %v", err) t.Errorf("Repositories.ListBranches returned error: %v", err)
} }
want := []*Branch{{Name: String("master"), Commit: &Commit{SHA: String("a57781"), URL: String("https://api.github.com/repos/o/r/commits/a57781")}}}
want := []*Branch{{Name: String("master"), Commit: &RepositoryCommit{SHA: String("a57781"), URL: String("https://api.github.com/repos/o/r/commits/a57781")}}}
if !reflect.DeepEqual(branches, want) { if !reflect.DeepEqual(branches, want) {
t.Errorf("Repositories.ListBranches returned %+v, want %+v", branches, want) t.Errorf("Repositories.ListBranches returned %+v, want %+v", branches, want)
} }
@ -447,7 +447,7 @@ func TestRepositoriesService_GetBranch(t *testing.T) {
mux.HandleFunc("/repos/o/r/branches/b", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("/repos/o/r/branches/b", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET") testMethod(t, r, "GET")
testHeader(t, r, "Accept", mediaTypeProtectedBranchesPreview) testHeader(t, r, "Accept", mediaTypeProtectedBranchesPreview)
fmt.Fprint(w, `{"name":"n", "commit":{"sha":"s"}, "protected":true}`)
fmt.Fprint(w, `{"name":"n", "commit":{"sha":"s","commit":{"message":"m"}}, "protected":true}`)
}) })
branch, _, err := client.Repositories.GetBranch("o", "r", "b") branch, _, err := client.Repositories.GetBranch("o", "r", "b")
@ -456,8 +456,13 @@ func TestRepositoriesService_GetBranch(t *testing.T) {
} }
want := &Branch{ want := &Branch{
Name: String("n"),
Commit: &Commit{SHA: String("s")},
Name: String("n"),
Commit: &RepositoryCommit{
SHA: String("s"),
Commit: &Commit{
Message: String("m"),
},
},
Protected: Bool(true), Protected: Bool(true),
} }


Loading…
Cancel
Save