From a608f5ef82e4f9b286e58d306b32638f2b602b47 Mon Sep 17 00:00:00 2001 From: Dan Carley Date: Thu, 15 Jan 2015 11:49:29 +0000 Subject: [PATCH] Add test for GitHub remote GetOrgs() helper I'm about to re-use this in another helper, so test that it works as expected. Also fix the inline documentation which was copied from `GetOrgRepos`. --- plugin/remote/github/helper.go | 2 +- plugin/remote/github/helper_test.go | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/plugin/remote/github/helper.go b/plugin/remote/github/helper.go index b55895a89..5bafccd8f 100644 --- a/plugin/remote/github/helper.go +++ b/plugin/remote/github/helper.go @@ -138,7 +138,7 @@ func GetOrgRepos(client *github.Client, org string) ([]github.Repository, error) } // GetOrgs is a helper function that returns a list of -// all org repositories. +// all orgs that a user belongs to. func GetOrgs(client *github.Client) ([]github.Organization, error) { orgs, _, err := client.Organizations.List("", nil) return orgs, err diff --git a/plugin/remote/github/helper_test.go b/plugin/remote/github/helper_test.go index 8bb060813..d5e6add33 100644 --- a/plugin/remote/github/helper_test.go +++ b/plugin/remote/github/helper_test.go @@ -12,13 +12,22 @@ func Test_Helper(t *testing.T) { var server = testdata.NewServer() defer server.Close() + var client = NewClient(server.URL, "sekret", false) + g := goblin.Goblin(t) g.Describe("GitHub Helper Functions", func() { g.It("Should Get a User") g.It("Should Get a User Primary Email") g.It("Should Get a User + Primary Email") - g.It("Should Get a list of Orgs") + + g.It("Should Get a list of Orgs", func() { + var orgs, err = GetOrgs(client) + g.Assert(err == nil).IsTrue() + g.Assert(len(orgs)).Equal(1) + g.Assert(*orgs[0].Login).Equal("octocats-inc") + }) + g.It("Should Get a list of User Repos") g.It("Should Get a list of Org Repos") g.It("Should Get a list of All Repos")