From c9a0030551f289241407743fbd21080cd8a358a4 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Wed, 30 Sep 2015 12:28:28 -0400 Subject: Moved ChannelMember.NotifyLevel into ChannelMember.NotifyProps --- api/channel_test.go | 84 +---------------------------------------------------- 1 file changed, 1 insertion(+), 83 deletions(-) (limited to 'api/channel_test.go') 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") } } -- cgit v1.2.3-1-g7c22