diff options
Diffstat (limited to 'api4/team_test.go')
-rw-r--r-- | api4/team_test.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/api4/team_test.go b/api4/team_test.go index 5c6d64ace..5f7bc7b98 100644 --- a/api4/team_test.go +++ b/api4/team_test.go @@ -192,3 +192,54 @@ func TestGetTeamMember(t *testing.T) { _, resp = th.SystemAdminClient.GetTeamMember(team.Id, user.Id, "") CheckNoError(t, resp) } + +func TestGetTeamStats(t *testing.T) { + th := Setup().InitBasic().InitSystemAdmin() + defer TearDown() + Client := th.Client + team := th.BasicTeam + + rstats, resp := Client.GetTeamStats(team.Id, "") + CheckNoError(t, resp) + + if rstats.TeamId != team.Id { + t.Fatal("wrong team id") + } + + if rstats.TotalMemberCount != 3 { + t.Fatal("wrong count") + } + + if rstats.ActiveMemberCount != 3 { + t.Fatal("wrong count") + } + + _, resp = Client.GetTeamStats("junk", "") + CheckBadRequestStatus(t, resp) + + _, resp = Client.GetTeamStats(model.NewId(), "") + CheckForbiddenStatus(t, resp) + + _, resp = th.SystemAdminClient.GetTeamStats(team.Id, "") + CheckNoError(t, resp) + + // deactivate BasicUser2 + th.UpdateActiveUser(th.BasicUser2, false) + + rstats, resp = th.SystemAdminClient.GetTeamStats(team.Id, "") + CheckNoError(t, resp) + + if rstats.TotalMemberCount != 3 { + t.Fatal("wrong count") + } + + if rstats.ActiveMemberCount != 2 { + t.Fatal("wrong count") + } + + // login with different user and test if forbidden + user := th.CreateUser() + Client.Login(user.Email, user.Password) + _, resp = Client.GetTeamStats(th.BasicTeam.Id, "") + CheckForbiddenStatus(t, resp) +} |