From 908ed5555f8a3d37cd057035b2792d66c8b7838a Mon Sep 17 00:00:00 2001 From: Carlos Tadeu Panato Junior Date: Sat, 13 Oct 2018 12:35:57 +0200 Subject: [APIv4] add getChannelMembersTimezone (#9286) * add getChannelMembersTimezone * update per feedback review * add delimeter to error --- app/channel_test.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'app/channel_test.go') 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)) +} -- cgit v1.2.3-1-g7c22