Skip to content

Commit 72979af

Browse files
authored
Merge pull request #8 from EPTribe/featGetTeam
[Team] Add GET method
2 parents c161b5b + a288c9f commit 72979af

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

team.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ func (c *Client) CreateTeam(o Organization, name string, slug *string) (Team, er
3030
return team, err
3131
}
3232

33+
// GetTeam takes a team slug and returns back the team
34+
func (c *Client) GetTeam(o Organization, teamSlug string) (Team, error) {
35+
var team Team
36+
err := c.do("GET", fmt.Sprintf("teams/%s/%s", *o.Slug, teamSlug), &team, nil)
37+
return team, err
38+
}
39+
3340
// UpdateTeam will update a team on the server side
3441
func (c *Client) UpdateTeam(o Organization, t Team) error {
3542
return c.do("PUT", fmt.Sprintf("teams/%s/%s", *o.Slug, *t.Slug), &t, &t)

team_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ func TestTeamResource(t *testing.T) {
4141
}
4242
})
4343

44+
t.Run("Fetch the team", func(t *testing.T) {
45+
team, err := client.GetTeam(org, *team.Slug)
46+
if err != nil {
47+
t.Error(err)
48+
}
49+
if team.Name != "Test team for Go Client" {
50+
t.Error("Failed to fetch team on server side")
51+
}
52+
})
53+
4454
t.Run("Update the team name", func(t *testing.T) {
4555
team.Name = "Updated team name for testing"
4656
err := client.UpdateTeam(org, team)

0 commit comments

Comments
 (0)