summaryrefslogtreecommitdiffstats
path: root/model/post_list_test.go
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2015-10-26 12:12:18 -0700
committerCorey Hulen <corey@hulen.com>2015-10-26 12:12:18 -0700
commit942c9317f4936e72da51b84313713b4ecd583b9a (patch)
tree94eea3c793e59910e78a5a842bb31c2b0d68b145 /model/post_list_test.go
parent86e3764cbd544c64136d5c34c2b80fb66a0cd4bd (diff)
parent663bec814767fa9c92e7ab2c706c0fe4c0432cf1 (diff)
downloadchat-942c9317f4936e72da51b84313713b4ecd583b9a.tar.gz
chat-942c9317f4936e72da51b84313713b4ecd583b9a.tar.bz2
chat-942c9317f4936e72da51b84313713b4ecd583b9a.zip
Merge pull request #1164 from hmhealey/plt778
PLT-778 Changed post searching to allow searching by multiple users/channels
Diffstat (limited to 'model/post_list_test.go')
-rw-r--r--model/post_list_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/model/post_list_test.go b/model/post_list_test.go
index 8a34327ce..9ce6447e1 100644
--- a/model/post_list_test.go
+++ b/model/post_list_test.go
@@ -34,3 +34,37 @@ func TestPostListJson(t *testing.T) {
t.Fatal("failed to serialize")
}
}
+
+func TestPostListExtend(t *testing.T) {
+ l1 := PostList{}
+
+ p1 := &Post{Id: NewId(), Message: NewId()}
+ l1.AddPost(p1)
+ l1.AddOrder(p1.Id)
+
+ p2 := &Post{Id: NewId(), Message: NewId()}
+ l1.AddPost(p2)
+ l1.AddOrder(p2.Id)
+
+ l2 := PostList{}
+
+ p3 := &Post{Id: NewId(), Message: NewId()}
+ l2.AddPost(p3)
+ l2.AddOrder(p3.Id)
+
+ l2.Extend(&l1)
+
+ if len(l1.Posts) != 2 || len(l1.Order) != 2 {
+ t.Fatal("extending l2 changed l1")
+ } else if len(l2.Posts) != 3 {
+ t.Fatal("failed to extend posts l2")
+ } else if l2.Order[0] != p3.Id || l2.Order[1] != p1.Id || l2.Order[2] != p2.Id {
+ t.Fatal("failed to extend order of l2")
+ }
+
+ if len(l1.Posts) != 2 || len(l1.Order) != 2 {
+ t.Fatal("extending l2 again changed l1")
+ } else if len(l2.Posts) != 3 || len(l2.Order) != 3 {
+ t.Fatal("extending l2 again changed l2")
+ }
+}