summaryrefslogtreecommitdiffstats
path: root/model/post_list_test.go
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-10-23 17:28:02 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-10-23 17:28:02 -0400
commit2383d5dd37d5ebf28c2576fd495a8a7f02f78901 (patch)
tree17e3b5953fc0f1392ec477948609a0d1ecc134fb /model/post_list_test.go
parent2ccf80d91d9f9236e15a674c7d2d61261538c9b9 (diff)
downloadchat-2383d5dd37d5ebf28c2576fd495a8a7f02f78901.tar.gz
chat-2383d5dd37d5ebf28c2576fd495a8a7f02f78901.tar.bz2
chat-2383d5dd37d5ebf28c2576fd495a8a7f02f78901.zip
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")
+ }
+}