Browse Source

simplify function names for listing public data

in the case of org members, combine ListPublicMembers() into
ListMembers(). fixes #8
Will Norris 13 years ago
parent
commit
822e5c6d98
4 changed files with 24 additions and 38 deletions
  1. +4
    -4
      github/activity_events.go
  2. +8
    -8
      github/activity_events_test.go
  3. +6
    -15
      github/orgs_members.go
  4. +6
    -11
      github/orgs_members_test.go

+ 4
- 4
github/activity_events.go View File

@ -70,10 +70,10 @@ func (p *PushEventCommit) String() string {
return Stringify(p)
}
// ListPublicEvents drinks from the firehose of all public events across GitHub.
// ListEvents drinks from the firehose of all public events across GitHub.
//
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-public-events
func (s *ActivityService) ListPublicEvents(opt *ListOptions) ([]Event, *Response, error) {
func (s *ActivityService) ListEvents(opt *ListOptions) ([]Event, *Response, error) {
u := "events"
if opt != nil {
params := url.Values{
@ -158,10 +158,10 @@ func (s *ActivityService) ListEventsForRepoNetwork(owner, repo string, opt *List
return *events, resp, err
}
// ListPublicEventsForOrganization lists public events for an organization.
// ListEventsForOrganization lists public events for an organization.
//
// GitHub API docs: http://developer.github.com/v3/activity/events/#list-public-events-for-an-organization
func (s *ActivityService) ListPublicEventsForOrganization(org string, opt *ListOptions) ([]Event, *Response, error) {
func (s *ActivityService) ListEventsForOrganization(org string, opt *ListOptions) ([]Event, *Response, error) {
u := fmt.Sprintf("orgs/%v/events", org)
if opt != nil {
params := url.Values{


+ 8
- 8
github/activity_events_test.go View File

@ -13,7 +13,7 @@ import (
"testing"
)
func TestActivityService_ListPublicEvents(t *testing.T) {
func TestActivityService_ListEvents(t *testing.T) {
setup()
defer teardown()
@ -26,14 +26,14 @@ func TestActivityService_ListPublicEvents(t *testing.T) {
})
opt := &ListOptions{Page: 2}
events, _, err := client.Activity.ListPublicEvents(opt)
events, _, err := client.Activity.ListEvents(opt)
if err != nil {
t.Errorf("Activities.ListPublicEvents returned error: %v", err)
t.Errorf("Activities.ListEvents returned error: %v", err)
}
want := []Event{{ID: String("1")}, {ID: String("2")}}
if !reflect.DeepEqual(events, want) {
t.Errorf("Activities.ListPublicEvents returned %+v, want %+v", events, want)
t.Errorf("Activities.ListEvents returned %+v, want %+v", events, want)
}
}
@ -109,7 +109,7 @@ func TestActivityService_ListEventsForRepoNetwork(t *testing.T) {
}
}
func TestActivityService_ListPublicEventsForOrganization(t *testing.T) {
func TestActivityService_ListEventsForOrganization(t *testing.T) {
setup()
defer teardown()
@ -122,14 +122,14 @@ func TestActivityService_ListPublicEventsForOrganization(t *testing.T) {
})
opt := &ListOptions{Page: 2}
events, _, err := client.Activity.ListPublicEventsForOrganization("o", opt)
events, _, err := client.Activity.ListEventsForOrganization("o", opt)
if err != nil {
t.Errorf("Activities.ListPublicEventsForOrganization returned error: %v", err)
t.Errorf("Activities.ListEventsForOrganization returned error: %v", err)
}
want := []Event{{ID: String("1")}, {ID: String("2")}}
if !reflect.DeepEqual(events, want) {
t.Errorf("Activities.ListPublicEventsForOrganization returned %+v, want %+v", events, want)
t.Errorf("Activities.ListEventsForOrganization returned %+v, want %+v", events, want)
}
}


+ 6
- 15
github/orgs_members.go View File

@ -12,23 +12,14 @@ import "fmt"
// public members, otherwise it will only return public members.
//
// GitHub API docs: http://developer.github.com/v3/orgs/members/#members-list
func (s *OrganizationsService) ListMembers(org string) ([]User, *Response, error) {
u := fmt.Sprintf("orgs/%v/members", org)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
func (s *OrganizationsService) ListMembers(org string, publicOnly bool) ([]User, *Response, error) {
var u string
if publicOnly {
u = fmt.Sprintf("orgs/%v/public_members", org)
} else {
u = fmt.Sprintf("orgs/%v/members", org)
}
members := new([]User)
resp, err := s.client.Do(req, members)
return *members, resp, err
}
// ListPublicMembers lists the public members for an organization.
//
// GitHub API docs: http://developer.github.com/v3/orgs/members/#public-members-list
func (s *OrganizationsService) ListPublicMembers(org string) ([]User, *Response, error) {
u := fmt.Sprintf("orgs/%v/public_members", org)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err


+ 6
- 11
github/orgs_members_test.go View File

@ -21,7 +21,7 @@ func TestOrganizationsService_ListMembers(t *testing.T) {
fmt.Fprint(w, `[{"id":1}]`)
})
members, _, err := client.Organizations.ListMembers("o")
members, _, err := client.Organizations.ListMembers("o", false)
if err != nil {
t.Errorf("Organizations.ListMembers returned error: %v", err)
}
@ -33,11 +33,11 @@ func TestOrganizationsService_ListMembers(t *testing.T) {
}
func TestOrganizationsService_ListMembers_invalidOrg(t *testing.T) {
_, _, err := client.Organizations.ListMembers("%")
_, _, err := client.Organizations.ListMembers("%", false)
testURLParseError(t, err)
}
func TestOrganizationsService_ListPublicMembers(t *testing.T) {
func TestOrganizationsService_ListMembers_public(t *testing.T) {
setup()
defer teardown()
@ -46,22 +46,17 @@ func TestOrganizationsService_ListPublicMembers(t *testing.T) {
fmt.Fprint(w, `[{"id":1}]`)
})
members, _, err := client.Organizations.ListPublicMembers("o")
members, _, err := client.Organizations.ListMembers("o", true)
if err != nil {
t.Errorf("Organizations.ListPublicMembers returned error: %v", err)
t.Errorf("Organizations.ListMembers returned error: %v", err)
}
want := []User{{ID: Int(1)}}
if !reflect.DeepEqual(members, want) {
t.Errorf("Organizations.ListPublicMembers returned %+v, want %+v", members, want)
t.Errorf("Organizations.ListMembers returned %+v, want %+v", members, want)
}
}
func TestOrganizationsService_ListPublicMembers_invalidOrg(t *testing.T) {
_, _, err := client.Organizations.ListPublicMembers("%")
testURLParseError(t, err)
}
func TestOrganizationsService_IsMember(t *testing.T) {
setup()
defer teardown()


Loading…
Cancel
Save