diff options
author | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2018-10-13 12:35:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-13 12:35:57 +0200 |
commit | 908ed5555f8a3d37cd057035b2792d66c8b7838a (patch) | |
tree | 7ad4248a72a7c3b6e6c3981840c5951c6108fe1d /app/channel_test.go | |
parent | e87965f39d2ce6dbd0e7883c387956413c663f6a (diff) | |
download | chat-908ed5555f8a3d37cd057035b2792d66c8b7838a.tar.gz chat-908ed5555f8a3d37cd057035b2792d66c8b7838a.tar.bz2 chat-908ed5555f8a3d37cd057035b2792d66c8b7838a.zip |
[APIv4] add getChannelMembersTimezone (#9286)
* add getChannelMembersTimezone
* update per feedback review
* add delimeter to error
Diffstat (limited to 'app/channel_test.go')
-rw-r--r-- | app/channel_test.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/app/channel_test.go b/app/channel_test.go index 4b09bbb78..b6f460741 100644 --- a/app/channel_test.go +++ b/app/channel_test.go @@ -4,6 +4,7 @@ package app import ( + "strings" "testing" "github.com/mattermost/mattermost-server/model" @@ -709,3 +710,40 @@ func TestRenameChannel(t *testing.T) { }) } } + +func TestGetChannelMembersTimezones(t *testing.T) { + th := Setup().InitBasic().InitSystemAdmin() + defer th.TearDown() + + userRequestorId := "" + postRootId := "" + if _, err := th.App.AddChannelMember(th.BasicUser2.Id, th.BasicChannel, userRequestorId, postRootId, false); err != nil { + t.Fatal("Failed to add user to channel. Error: " + err.Message) + } + + user := th.BasicUser + user.Timezone["useAutomaticTimezone"] = "false" + user.Timezone["manualTimezone"] = "XOXO/BLABLA" + th.App.UpdateUser(user, false) + + user2 := th.BasicUser2 + user2.Timezone["automaticTimezone"] = "NoWhere/Island" + th.App.UpdateUser(user2, false) + + user3 := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""} + ruser, _ := th.App.CreateUser(&user3) + th.App.AddUserToChannel(ruser, th.BasicChannel) + + ruser.Timezone["automaticTimezone"] = "NoWhere/Island" + th.App.UpdateUser(ruser, false) + + user4 := model.User{Email: strings.ToLower(model.NewId()) + "success+test@example.com", Nickname: "Darth Vader", Username: "vader" + model.NewId(), Password: "passwd1", AuthService: ""} + ruser, _ = th.App.CreateUser(&user4) + th.App.AddUserToChannel(ruser, th.BasicChannel) + + timezones, err := th.App.GetChannelMembersTimezones(th.BasicChannel.Id) + if err != nil { + t.Fatal("Failed to get the timezones for a channel. Error: " + err.Error()) + } + assert.Equal(t, 2, len(timezones)) +} |