summaryrefslogtreecommitdiffstats
path: root/api/post_test.go
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2016-12-30 17:44:05 +0100
committerenahum <nahumhbl@gmail.com>2016-12-30 13:44:04 -0300
commit21af988e4973a7c51a6b48814bb0366454410c72 (patch)
treeb3ec979fd2a2aa4bb2c9b50e5f3e8b37486910d0 /api/post_test.go
parent42da7aa700cb34b77134d36b5ae9e530f80502cc (diff)
downloadchat-21af988e4973a7c51a6b48814bb0366454410c72.tar.gz
chat-21af988e4973a7c51a6b48814bb0366454410c72.tar.bz2
chat-21af988e4973a7c51a6b48814bb0366454410c72.zip
Add initial unit test for post.getPostById() (#4910)
* add itinial tests for GetPostById update per review fix lint * add missing comment
Diffstat (limited to 'api/post_test.go')
-rw-r--r--api/post_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/api/post_test.go b/api/post_test.go
index fd0c0b24b..eb01195db 100644
--- a/api/post_test.go
+++ b/api/post_test.go
@@ -1360,3 +1360,33 @@ func TestSendNotifications(t *testing.T) {
t.Fatal("user should have been mentioned")
}
}
+
+func TestGetPostById(t *testing.T) {
+ th := Setup().InitBasic()
+ Client := th.BasicClient
+ channel1 := th.BasicChannel
+
+ time.Sleep(10 * time.Millisecond)
+ post1 := &model.Post{ChannelId: channel1.Id, Message: "yommamma" + model.NewId() + "a"}
+ post1 = Client.Must(Client.CreatePost(post1)).Data.(*model.Post)
+
+ if post, respMetadata := Client.GetPostById(post1.Id, ""); respMetadata.Error != nil {
+ t.Fatal(respMetadata.Error)
+ } else {
+ if len(post.Order) != 1 {
+ t.Fatal("should be just one post")
+ }
+
+ if post.Order[0] != post1.Id {
+ t.Fatal("wrong order")
+ }
+
+ if post.Posts[post.Order[0]].Message != post1.Message {
+ t.Fatal("wrong message from post")
+ }
+ }
+
+ if _, respMetadata := Client.GetPostById("45345435345345", ""); respMetadata.Error == nil {
+ t.Fatal(respMetadata.Error)
+ }
+}