summaryrefslogtreecommitdiffstats
path: root/api4/team_test.go
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2017-02-18 05:50:17 +0900
committerJoram Wilander <jwawilander@gmail.com>2017-02-17 15:50:17 -0500
commit00d11e961f6a32f7d4880c40fd6359574d665a4e (patch)
treeac03d114664413c0f2495815883bc7a861a33b1e /api4/team_test.go
parent91fe8bb2c0d520f13269b2eadc2717a5ec4eea1c (diff)
downloadchat-00d11e961f6a32f7d4880c40fd6359574d665a4e.tar.gz
chat-00d11e961f6a32f7d4880c40fd6359574d665a4e.tar.bz2
chat-00d11e961f6a32f7d4880c40fd6359574d665a4e.zip
Implement GET teams/{team_id}/stats - apiv4 (#5453)
* api4 GET teams/{team_id}/stats * api4 GET teams/{team_id}/stats * moved TeamStats router to team.go
Diffstat (limited to 'api4/team_test.go')
-rw-r--r--api4/team_test.go51
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)
+}