diff options
author | JoramWilander <jwawilander@gmail.com> | 2015-08-11 09:28:44 -0400 |
---|---|---|
committer | JoramWilander <jwawilander@gmail.com> | 2015-08-11 12:11:35 -0400 |
commit | 3d0133b5e85660b942773f7cc63e6e8bc357462c (patch) | |
tree | 55df252b0d5a6e34a6b1e45348a361ea27d8144a /api/channel_test.go | |
parent | 9f57ed5bf12d2d3a4cb143985c80646b877a1706 (diff) | |
download | chat-3d0133b5e85660b942773f7cc63e6e8bc357462c.tar.gz chat-3d0133b5e85660b942773f7cc63e6e8bc357462c.tar.bz2 chat-3d0133b5e85660b942773f7cc63e6e8bc357462c.zip |
added api unit test for GetChannelCounts
Diffstat (limited to 'api/channel_test.go')
-rw-r--r-- | api/channel_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/api/channel_test.go b/api/channel_test.go index a0c2a6467..5563c692e 100644 --- a/api/channel_test.go +++ b/api/channel_test.go @@ -387,6 +387,40 @@ func TestGetMoreChannel(t *testing.T) { } } +func TestGetChannelCounts(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() + "corey@test.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: "A Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id} + channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel) + + channel2 := &model.Channel{DisplayName: "B Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id} + channel2 = Client.Must(Client.CreateChannel(channel2)).Data.(*model.Channel) + + if result, err := Client.GetChannelCounts(""); err != nil { + t.Fatal(err) + } else { + counts := result.Data.(*model.ChannelCounts) + + if len(counts.Counts) != 4 { + t.Fatal("wrong number of channel counts") + } + + if len(counts.UpdateTimes) != 4 { + t.Fatal("wrong number of channel update times") + } + } + +} + func TestJoinChannel(t *testing.T) { Setup() |