mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-27 19:00:35 +00:00
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:
parent
86b0329d57
commit
a608f5ef82
2 changed files with 11 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue