diff options
author | Christopher Speller <crspeller@gmail.com> | 2015-08-14 08:35:19 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2015-08-14 08:35:19 -0400 |
commit | a8930cbabec21635a10e8cac4d2c0c79867f283d (patch) | |
tree | a622f8d94fa1b60753896640c1f8c1a5ebaf48e2 /api/channel_test.go | |
parent | b1d37e9c385f0d3e9bddd9dffe1570574dcdcab6 (diff) | |
parent | 2485b87b28a7fed1996d627b48dcd94f19002fc8 (diff) | |
download | chat-a8930cbabec21635a10e8cac4d2c0c79867f283d.tar.gz chat-a8930cbabec21635a10e8cac4d2c0c79867f283d.tar.bz2 chat-a8930cbabec21635a10e8cac4d2c0c79867f283d.zip |
Merge pull request #365 from mattermost/mm-1700
MM-1700 don't pull all channel data all the time
Diffstat (limited to 'api/channel_test.go')
-rw-r--r-- | api/channel_test.go | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/api/channel_test.go b/api/channel_test.go index d4fb11bd8..d65aff66c 100644 --- a/api/channel_test.go +++ b/api/channel_test.go @@ -320,6 +320,27 @@ func TestGetChannel(t *testing.T) { if _, err := Client.UpdateLastViewedAt(channel2.Id); err != nil { t.Fatal(err) } + + if resp, err := Client.GetChannel(channel1.Id, ""); err != nil { + t.Fatal(err) + } else { + data := resp.Data.(*model.ChannelData) + if data.Channel.DisplayName != channel1.DisplayName { + t.Fatal("name didn't match") + } + + // test etag caching + if cache_result, err := Client.GetChannel(channel1.Id, resp.Etag); err != nil { + t.Fatal(err) + } else if cache_result.Data.(*model.ChannelData) != nil { + t.Log(cache_result.Data) + t.Fatal("cache should be empty") + } + } + + if _, err := Client.GetChannel("junk", ""); err == nil { + t.Fatal("should have failed - bad channel id") + } } func TestGetMoreChannel(t *testing.T) { @@ -366,6 +387,47 @@ 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") + } + + if cache_result, err := Client.GetChannelCounts(result.Etag); err != nil { + t.Fatal(err) + } else if cache_result.Data.(*model.ChannelCounts) != nil { + t.Log(cache_result.Data) + t.Fatal("result data should be empty") + } + } + +} + func TestJoinChannel(t *testing.T) { Setup() |