diff options
author | Debanshu Kundu <debanshu.kundu@joshtechnologygroup.com> | 2017-07-31 23:47:21 +0530 |
---|---|---|
committer | Saturnino Abril <saturnino.abril@gmail.com> | 2017-08-01 02:17:21 +0800 |
commit | 8a91235fb3cdc8d094dbc2eaa0d7baa447132b3c (patch) | |
tree | 28496b27f4da93baa8707bf0690ef88f8cdcc178 /store/sql_post_store_test.go | |
parent | 59992ae4a4638006ec1489dd834151b258c1728c (diff) | |
download | chat-8a91235fb3cdc8d094dbc2eaa0d7baa447132b3c.tar.gz chat-8a91235fb3cdc8d094dbc2eaa0d7baa447132b3c.tar.bz2 chat-8a91235fb3cdc8d094dbc2eaa0d7baa447132b3c.zip |
#4755 Combining consecutive user join/leave system messages to single message and few other changes. (#5945)
fix 7 and 8
remove @ at "{username} joined the channel"
refactor and update test
Diffstat (limited to 'store/sql_post_store_test.go')
-rw-r--r-- | store/sql_post_store_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/store/sql_post_store_test.go b/store/sql_post_store_test.go index 27e816996..761e0dcdf 100644 --- a/store/sql_post_store_test.go +++ b/store/sql_post_store_test.go @@ -1661,3 +1661,37 @@ func TestPostStoreGetPostsBatchForIndexing(t *testing.T) { } } } + +func TestGetLastPostForChannel(t *testing.T) { + Setup() + + o1 := &model.Post{} + o1.ChannelId = model.NewId() + o1.UserId = model.NewId() + o1.Message = "" + o1.Type = model.POST_JOIN_CHANNEL + + o1 = (<-store.Post().Save(o1)).Data.(*model.Post) + + if r1 := <-store.Post().GetLastPostForChannel(o1.ChannelId); r1.Err != nil { + t.Fatal(r1.Err) + } else { + if r1.Data.(*model.Post).Id != o1.Id { + t.Fatal("invalid returned post") + } + } + + o2 := &model.Post{} + o2.ChannelId = o1.ChannelId + o2.UserId = model.NewId() + o2.Message = "" + + o2 = (<-store.Post().Save(o2)).Data.(*model.Post) + if r2 := <-store.Post().GetLastPostForChannel(o2.ChannelId); r2.Err != nil { + t.Fatal(r2.Err) + } else { + if r2.Data.(*model.Post).Id != o2.Id { + t.Fatal("invalid returned post") + } + } +} |