diff options
author | =Corey Hulen <corey@hulen.com> | 2015-08-02 09:41:12 -0800 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-08-02 09:41:12 -0800 |
commit | 247708d924770737a3c03f956b19d8096da2bdea (patch) | |
tree | 3d6bd381545e660808f74a1379048e57cc0c6717 /api/channel_test.go | |
parent | e76fc37b6df7d53ea86a5b42009d5d1161741270 (diff) | |
parent | 718d670d699e295fcad903d507bc989c51a1ef50 (diff) | |
download | chat-247708d924770737a3c03f956b19d8096da2bdea.tar.gz chat-247708d924770737a3c03f956b19d8096da2bdea.tar.bz2 chat-247708d924770737a3c03f956b19d8096da2bdea.zip |
Merge branch 'master' into mm-1619
Diffstat (limited to 'api/channel_test.go')
-rw-r--r-- | api/channel_test.go | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/api/channel_test.go b/api/channel_test.go index a8d53c4b5..d4fb11bd8 100644 --- a/api/channel_test.go +++ b/api/channel_test.go @@ -6,6 +6,7 @@ package api import ( "github.com/mattermost/platform/model" "github.com/mattermost/platform/store" + "github.com/mattermost/platform/utils" "net/http" "testing" "time" @@ -543,10 +544,73 @@ func TestGetChannelExtraInfo(t *testing.T) { 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) - rget := Client.Must(Client.GetChannelExtraInfo(channel1.Id)).Data.(*model.ChannelExtra) - if rget.Id != channel1.Id { + rget := Client.Must(Client.GetChannelExtraInfo(channel1.Id, "")) + data := rget.Data.(*model.ChannelExtra) + if data.Id != channel1.Id { t.Fatal("couldnt't get extra info") } + + // + // Testing etag caching + // + + currentEtag := rget.Etag + + if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, currentEtag); err != nil { + t.Fatal(err) + } else if cache_result.Data.(*model.ChannelExtra) != nil { + t.Log(cache_result.Data) + t.Fatal("response should be empty") + } else { + currentEtag = cache_result.Etag + } + + Client2 := model.NewClient("http://localhost:" + utils.Cfg.ServiceSettings.Port + "/api/v1") + + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "tester2@test.com", Nickname: "Tester 2", Password: "pwd"} + user2 = Client2.Must(Client2.CreateUser(user2, "")).Data.(*model.User) + store.Must(Srv.Store.User().VerifyEmail(user2.Id)) + + Client2.LoginByEmail(team.Name, user2.Email, "pwd") + Client2.Must(Client2.JoinChannel(channel1.Id)) + + if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, currentEtag); err != nil { + t.Fatal(err) + } else if cache_result.Data.(*model.ChannelExtra) == nil { + t.Log(cache_result.Data) + t.Fatal("response should not be empty") + } else { + currentEtag = cache_result.Etag + } + + if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, currentEtag); err != nil { + t.Fatal(err) + } else if cache_result.Data.(*model.ChannelExtra) != nil { + t.Log(cache_result.Data) + t.Fatal("response should be empty") + } else { + currentEtag = cache_result.Etag + } + + Client2.Must(Client2.LeaveChannel(channel1.Id)) + + if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, currentEtag); err != nil { + t.Fatal(err) + } else if cache_result.Data.(*model.ChannelExtra) == nil { + t.Log(cache_result.Data) + t.Fatal("response should not be empty") + } else { + currentEtag = cache_result.Etag + } + + if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, currentEtag); err != nil { + t.Fatal(err) + } else if cache_result.Data.(*model.ChannelExtra) != nil { + t.Log(cache_result.Data) + t.Fatal("response should be empty") + } else { + currentEtag = cache_result.Etag + } } func TestAddChannelMember(t *testing.T) { |