diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-10-21 16:23:59 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-10-21 16:23:59 -0400 |
commit | 38855327502420f06d1235d9ac34a66d0bcbca34 (patch) | |
tree | 0dd0fd379f7dfd377b018172ff4b7e07e1ba1ab6 /api/post_test.go | |
parent | 254cefee1af5fbe12eb03c5246e1ca7f18275bbe (diff) | |
download | chat-38855327502420f06d1235d9ac34a66d0bcbca34.tar.gz chat-38855327502420f06d1235d9ac34a66d0bcbca34.tar.bz2 chat-38855327502420f06d1235d9ac34a66d0bcbca34.zip |
Fix notifications for public/private channels and add basic unit test (#4295)
Diffstat (limited to 'api/post_test.go')
-rw-r--r-- | api/post_test.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/api/post_test.go b/api/post_test.go index 3c917aec3..0bafb5d20 100644 --- a/api/post_test.go +++ b/api/post_test.go @@ -1273,3 +1273,41 @@ func TestGetFileInfosForPost(t *testing.T) { t.Fatal("should've returned nothing because of etag") } } + +// TODO: Needs to be vastly fleshed out +func TestSendNotifications(t *testing.T) { + th := Setup().InitBasic() + Client := th.BasicClient + + AddUserToChannel(th.BasicUser2, th.BasicChannel) + + mockSession := model.Session{ + UserId: th.BasicUser.Id, + TeamMembers: []*model.TeamMember{{TeamId: th.BasicTeam.Id, UserId: th.BasicUser.Id}}, + IsOAuth: false, + } + + newContext := &Context{ + Session: mockSession, + RequestId: model.NewId(), + IpAddress: "", + Path: "fake", + Err: nil, + siteURL: *utils.Cfg.ServiceSettings.SiteURL, + TeamId: th.BasicTeam.Id, + } + + post1 := Client.Must(Client.CreatePost(&model.Post{ + ChannelId: th.BasicChannel.Id, + Message: "@" + th.BasicUser2.Username, + })).Data.(*model.Post) + + mentions := sendNotifications(newContext, post1, th.BasicTeam, th.BasicChannel) + if mentions == nil { + t.Log(mentions) + t.Fatal("user should have been mentioned") + } else if mentions[0] != th.BasicUser2.Id { + t.Log(mentions) + t.Fatal("user should have been mentioned") + } +} |