summaryrefslogtreecommitdiffstats
path: root/store/sql_post_store_test.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-12-22 18:14:54 -0500
committerCorey Hulen <corey@hulen.com>2016-12-22 15:14:54 -0800
commitffd6ccde2ed4b1d374d0835c5638a189df60a679 (patch)
tree5b67ceff84678b04cdae08cef554086c4145324e /store/sql_post_store_test.go
parentca61b4bed94ea98530bf4f1b2f7585fe86ef80cd (diff)
downloadchat-ffd6ccde2ed4b1d374d0835c5638a189df60a679.tar.gz
chat-ffd6ccde2ed4b1d374d0835c5638a189df60a679.tar.bz2
chat-ffd6ccde2ed4b1d374d0835c5638a189df60a679.zip
Adding caching of last 60 posts. (#4880)
Diffstat (limited to 'store/sql_post_store_test.go')
-rw-r--r--store/sql_post_store_test.go28
1 files changed, 27 insertions, 1 deletions
diff --git a/store/sql_post_store_test.go b/store/sql_post_store_test.go
index 3299d67e1..eb22979db 100644
--- a/store/sql_post_store_test.go
+++ b/store/sql_post_store_test.go
@@ -491,7 +491,7 @@ func TestPostStoreGetPostsWtihDetails(t *testing.T) {
o5.RootId = o4.Id
o5 = (<-store.Post().Save(o5)).Data.(*model.Post)
- r1 := (<-store.Post().GetPosts(o1.ChannelId, 0, 4)).Data.(*model.PostList)
+ r1 := (<-store.Post().GetPosts(o1.ChannelId, 0, 4, false)).Data.(*model.PostList)
if r1.Order[0] != o5.Id {
t.Fatal("invalid order")
@@ -516,6 +516,32 @@ func TestPostStoreGetPostsWtihDetails(t *testing.T) {
if r1.Posts[o1.Id].Message != o1.Message {
t.Fatal("Missing parent")
}
+
+ r2 := (<-store.Post().GetPosts(o1.ChannelId, 0, 4, true)).Data.(*model.PostList)
+
+ if r2.Order[0] != o5.Id {
+ t.Fatal("invalid order")
+ }
+
+ if r2.Order[1] != o4.Id {
+ t.Fatal("invalid order")
+ }
+
+ if r2.Order[2] != o3.Id {
+ t.Fatal("invalid order")
+ }
+
+ if r2.Order[3] != o2a.Id {
+ t.Fatal("invalid order")
+ }
+
+ if len(r2.Posts) != 6 { //the last 4, + o1 (o2a and o3's parent) + o2 (in same thread as o2a and o3)
+ t.Fatal("wrong size")
+ }
+
+ if r2.Posts[o1.Id].Message != o1.Message {
+ t.Fatal("Missing parent")
+ }
}
func TestPostStoreGetPostsBeforeAfter(t *testing.T) {