summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2016-01-27 07:37:05 -0500
committerJoramWilander <jwawilander@gmail.com>2016-01-27 07:37:05 -0500
commitc4cca4d41835bb5a2532adb8be05bdd2c97d2544 (patch)
tree165585e0dc3a9a9a356a8cf6181306836d5a04ba /api
parentfb794f03c136673378cb8af7c92cc0f307e55f73 (diff)
downloadchat-c4cca4d41835bb5a2532adb8be05bdd2c97d2544.tar.gz
chat-c4cca4d41835bb5a2532adb8be05bdd2c97d2544.tar.bz2
chat-c4cca4d41835bb5a2532adb8be05bdd2c97d2544.zip
Updated search test cases
Diffstat (limited to 'api')
-rw-r--r--api/post_test.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/api/post_test.go b/api/post_test.go
index a18c72082..72abcd5cc 100644
--- a/api/post_test.go
+++ b/api/post_test.go
@@ -613,7 +613,10 @@ func TestSearchPostsFromUser(t *testing.T) {
t.Fatalf("wrong number of posts returned %v", len(result.Order))
}
- if result := Client.Must(Client.SearchPosts("from: " + user2.Username + " in:" + channel1.Name)).Data.(*model.PostList); len(result.Order) != 0 {
+ post3 := &model.Post{ChannelId: channel1.Id, Message: "hullo"}
+ post3 = Client.Must(Client.CreatePost(post3)).Data.(*model.Post)
+
+ if result := Client.Must(Client.SearchPosts("from: " + user2.Username + " in:" + channel1.Name)).Data.(*model.PostList); len(result.Order) != 1 {
t.Fatalf("wrong number of posts returned %v", len(result.Order))
}
@@ -628,11 +631,11 @@ func TestSearchPostsFromUser(t *testing.T) {
// wait for the join/leave messages to be created for user3 since they're done asynchronously
time.Sleep(100 * time.Millisecond)
- if result := Client.Must(Client.SearchPosts("from: " + user2.Username)).Data.(*model.PostList); len(result.Order) != 1 {
+ if result := Client.Must(Client.SearchPosts("from: " + user2.Username)).Data.(*model.PostList); len(result.Order) != 2 {
t.Fatalf("wrong number of posts returned %v", len(result.Order))
}
- if result := Client.Must(Client.SearchPosts("from: " + user2.Username + " from: " + user3.Username)).Data.(*model.PostList); len(result.Order) != 1 {
+ if result := Client.Must(Client.SearchPosts("from: " + user2.Username + " from: " + user3.Username)).Data.(*model.PostList); len(result.Order) != 2 {
t.Fatalf("wrong number of posts returned %v", len(result.Order))
}
@@ -640,7 +643,10 @@ func TestSearchPostsFromUser(t *testing.T) {
t.Fatalf("wrong number of posts returned %v", len(result.Order))
}
- if result := Client.Must(Client.SearchPosts("from: " + user2.Username + " from: " + user3.Username + " in:" + channel2.Name + " joined")).Data.(*model.PostList); len(result.Order) != 0 {
+ post4 := &model.Post{ChannelId: channel2.Id, Message: "coconut"}
+ post4 = Client.Must(Client.CreatePost(post4)).Data.(*model.Post)
+
+ if result := Client.Must(Client.SearchPosts("from: " + user2.Username + " from: " + user3.Username + " in:" + channel2.Name + " coconut")).Data.(*model.PostList); len(result.Order) != 1 {
t.Fatalf("wrong number of posts returned %v", len(result.Order))
}
}