summaryrefslogtreecommitdiffstats
path: root/api/admin_test.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2016-02-02 08:41:02 -0500
committerJoramWilander <jwawilander@gmail.com>2016-02-02 08:41:02 -0500
commit3d03bdf2f1af5385c2150544977fbba89650b1ee (patch)
tree77936a01b35e91bfb4126f5a9f4c5a4660130ae4 /api/admin_test.go
parentf28486c4553f7f4bccf7bf69153c2f12699705f9 (diff)
downloadchat-3d03bdf2f1af5385c2150544977fbba89650b1ee.tar.gz
chat-3d03bdf2f1af5385c2150544977fbba89650b1ee.tar.bz2
chat-3d03bdf2f1af5385c2150544977fbba89650b1ee.zip
Added extra system-wide statistics for EE
Diffstat (limited to 'api/admin_test.go')
-rw-r--r--api/admin_test.go110
1 files changed, 110 insertions, 0 deletions
diff --git a/api/admin_test.go b/api/admin_test.go
index 2552e642c..053a2a730 100644
--- a/api/admin_test.go
+++ b/api/admin_test.go
@@ -362,3 +362,113 @@ func TestUserCountsWithPostsByDay(t *testing.T) {
}
}
}
+
+func TestGetTeamAnalyticsExtra(t *testing.T) {
+ Setup()
+
+ team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
+ team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team)
+
+ user := &model.User{TeamId: team.Id, Email: model.NewId() + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "pwd"}
+ user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
+ store.Must(Srv.Store.User().VerifyEmail(user.Id))
+
+ Client.LoginByEmail(team.Name, user.Email, "pwd")
+
+ channel1 := &model.Channel{DisplayName: "TestGetPosts", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_PRIVATE, TeamId: team.Id}
+ channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel)
+
+ post1 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a"}
+ post1 = Client.Must(Client.CreatePost(post1)).Data.(*model.Post)
+
+ post2 := &model.Post{ChannelId: channel1.Id, Message: "#test a" + model.NewId() + "a"}
+ post2 = Client.Must(Client.CreatePost(post2)).Data.(*model.Post)
+
+ if _, err := Client.GetTeamAnalytics("", "extra_counts"); err == nil {
+ t.Fatal("Shouldn't have permissions")
+ }
+
+ c := &Context{}
+ c.RequestId = model.NewId()
+ c.IpAddress = "cmd_line"
+ UpdateRoles(c, user, model.ROLE_SYSTEM_ADMIN)
+
+ Client.LoginByEmail(team.Name, user.Email, "pwd")
+
+ if result, err := Client.GetTeamAnalytics(team.Id, "extra_counts"); err != nil {
+ t.Fatal(err)
+ } else {
+ rows := result.Data.(model.AnalyticsRows)
+
+ if rows[0].Name != "file_post_count" {
+ t.Log(rows.ToJson())
+ t.Fatal()
+ }
+
+ if rows[0].Value != 0 {
+ t.Log(rows.ToJson())
+ t.Fatal()
+ }
+
+ if rows[1].Name != "hashtag_post_count" {
+ t.Log(rows.ToJson())
+ t.Fatal()
+ }
+
+ if rows[1].Value != 1 {
+ t.Log(rows.ToJson())
+ t.Fatal()
+ }
+
+ if rows[2].Name != "incoming_webhook_count" {
+ t.Log(rows.ToJson())
+ t.Fatal()
+ }
+
+ if rows[2].Value != 0 {
+ t.Log(rows.ToJson())
+ t.Fatal()
+ }
+
+ if rows[3].Name != "outgoing_webhook_count" {
+ t.Log(rows.ToJson())
+ t.Fatal()
+ }
+
+ if rows[3].Value != 0 {
+ t.Log(rows.ToJson())
+ t.Fatal()
+ }
+ }
+
+ if result, err := Client.GetSystemAnalytics("extra_counts"); err != nil {
+ t.Fatal(err)
+ } else {
+ rows := result.Data.(model.AnalyticsRows)
+
+ if rows[0].Name != "file_post_count" {
+ t.Log(rows.ToJson())
+ t.Fatal()
+ }
+
+ if rows[1].Name != "hashtag_post_count" {
+ t.Log(rows.ToJson())
+ t.Fatal()
+ }
+
+ if rows[1].Value < 1 {
+ t.Log(rows.ToJson())
+ t.Fatal()
+ }
+
+ if rows[2].Name != "incoming_webhook_count" {
+ t.Log(rows.ToJson())
+ t.Fatal()
+ }
+
+ if rows[3].Name != "outgoing_webhook_count" {
+ t.Log(rows.ToJson())
+ t.Fatal()
+ }
+ }
+}