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`.
This commit is contained in:
Dan Carley 2015-01-15 11:49:29 +00:00
parent 86b0329d57
commit a608f5ef82
2 changed files with 11 additions and 2 deletions

View file

@ -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

View file

@ -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")