summaryrefslogtreecommitdiffstats
path: root/api/channel_test.go
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-09-30 12:28:28 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-10-01 08:31:17 -0400
commitc9a0030551f289241407743fbd21080cd8a358a4 (patch)
tree03019a8ad970ebd66d7f5bd1a84d11fcdb76f1ff /api/channel_test.go
parentc16b9de8dc4924cf2fb243579284e67f55cf3a47 (diff)
downloadchat-c9a0030551f289241407743fbd21080cd8a358a4.tar.gz
chat-c9a0030551f289241407743fbd21080cd8a358a4.tar.bz2
chat-c9a0030551f289241407743fbd21080cd8a358a4.zip
Moved ChannelMember.NotifyLevel into ChannelMember.NotifyProps
Diffstat (limited to 'api/channel_test.go')
-rw-r--r--api/channel_test.go84
1 files changed, 1 insertions, 83 deletions
diff --git a/api/channel_test.go b/api/channel_test.go
index 0e9dbbd41..e6c7ed80e 100644
--- a/api/channel_test.go
+++ b/api/channel_test.go
@@ -803,88 +803,6 @@ func TestRemoveChannelMember(t *testing.T) {
}
-func TestUpdateNotifyLevel(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)
-
- data := make(map[string]string)
- data["channel_id"] = channel1.Id
- data["user_id"] = user.Id
- data["notify_level"] = model.CHANNEL_NOTIFY_MENTION
-
- timeBeforeUpdate := model.GetMillis()
- time.Sleep(100 * time.Millisecond)
-
- if _, err := Client.UpdateNotifyLevel(data); err != nil {
- t.Fatal(err)
- }
-
- rget := Client.Must(Client.GetChannels(""))
- rdata := rget.Data.(*model.ChannelList)
- if len(rdata.Members) == 0 || rdata.Members[channel1.Id].NotifyLevel != data["notify_level"] {
- t.Fatal("NotifyLevel did not update properly")
- }
-
- if rdata.Members[channel1.Id].LastUpdateAt <= timeBeforeUpdate {
- t.Fatal("LastUpdateAt did not update")
- }
-
- data["user_id"] = "junk"
- if _, err := Client.UpdateNotifyLevel(data); err == nil {
- t.Fatal("Should have errored - bad user id")
- }
-
- data["user_id"] = "12345678901234567890123456"
- if _, err := Client.UpdateNotifyLevel(data); err == nil {
- t.Fatal("Should have errored - bad user id")
- }
-
- data["user_id"] = user.Id
- data["channel_id"] = "junk"
- if _, err := Client.UpdateNotifyLevel(data); err == nil {
- t.Fatal("Should have errored - bad channel id")
- }
-
- data["channel_id"] = "12345678901234567890123456"
- if _, err := Client.UpdateNotifyLevel(data); err == nil {
- t.Fatal("Should have errored - bad channel id")
- }
-
- data["channel_id"] = channel1.Id
- data["notify_level"] = ""
- if _, err := Client.UpdateNotifyLevel(data); err == nil {
- t.Fatal("Should have errored - empty notify level")
- }
-
- data["notify_level"] = "junk"
- if _, err := Client.UpdateNotifyLevel(data); err == nil {
- t.Fatal("Should have errored - bad notify level")
- }
-
- user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey@test.com", Nickname: "Corey Hulen", Password: "pwd"}
- user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
-
- Client.LoginByEmail(team.Name, user2.Email, "pwd")
-
- data["channel_id"] = channel1.Id
- data["user_id"] = user2.Id
- data["notify_level"] = model.CHANNEL_NOTIFY_MENTION
- if _, err := Client.UpdateNotifyLevel(data); err == nil {
- t.Fatal("Should have errored - user not in channel")
- }
-}
-
func TestUpdateNotifyProps(t *testing.T) {
Setup()
@@ -1002,7 +920,7 @@ func TestUpdateNotifyProps(t *testing.T) {
data["user_id"] = user2.Id
data["desktop"] = model.CHANNEL_NOTIFY_MENTION
data["mark_unread"] = model.CHANNEL_MARK_UNREAD_MENTION
- if _, err := Client.UpdateNotifyLevel(data); err == nil {
+ if _, err := Client.UpdateNotifyProps(data); err == nil {
t.Fatal("Should have errored - user not in channel")
}
}