diff options
author | Gabin Aureche <gabin.aureche@live.fr> | 2017-03-13 13:25:08 +0100 |
---|---|---|
committer | George Goldberg <george@gberg.me> | 2017-03-13 12:25:08 +0000 |
commit | fe38d6d5bb36e18ddefbe490cc21f48f4f4c8d81 (patch) | |
tree | b96d457cde64b7397f91028106e93a7f92a179bd /api/post_test.go | |
parent | 482a0fb5fc248b1ec61db35299dc3e6d963ad5ab (diff) | |
download | chat-fe38d6d5bb36e18ddefbe490cc21f48f4f4c8d81.tar.gz chat-fe38d6d5bb36e18ddefbe490cc21f48f4f4c8d81.tar.bz2 chat-fe38d6d5bb36e18ddefbe490cc21f48f4f4c8d81.zip |
Add pinned posts (#4217)
Diffstat (limited to 'api/post_test.go')
-rw-r--r-- | api/post_test.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/api/post_test.go b/api/post_test.go index bab27cc65..5546e7165 100644 --- a/api/post_test.go +++ b/api/post_test.go @@ -1378,3 +1378,49 @@ func TestGetOpenGraphMetadata(t *testing.T) { t.Fatal("should have failed with 501 - disabled link previews") } } + +func TestPinPost(t *testing.T) { + th := Setup().InitBasic() + Client := th.BasicClient + + post := th.BasicPost + if rupost1, err := Client.PinPost(post.ChannelId, post.Id); err != nil { + t.Fatal(err) + } else { + if rupost1.Data.(*model.Post).IsPinned != true { + t.Fatal("failed to pin post") + } + } + + pinnedPost := th.PinnedPost + if rupost2, err := Client.PinPost(pinnedPost.ChannelId, pinnedPost.Id); err != nil { + t.Fatal(err) + } else { + if rupost2.Data.(*model.Post).IsPinned != true { + t.Fatal("pinning a post should be idempotent") + } + } +} + +func TestUnpinPost(t *testing.T) { + th := Setup().InitBasic() + Client := th.BasicClient + + pinnedPost := th.PinnedPost + if rupost1, err := Client.UnpinPost(pinnedPost.ChannelId, pinnedPost.Id); err != nil { + t.Fatal(err) + } else { + if rupost1.Data.(*model.Post).IsPinned != false { + t.Fatal("failed to unpin post") + } + } + + post := th.BasicPost + if rupost2, err := Client.UnpinPost(post.ChannelId, post.Id); err != nil { + t.Fatal(err) + } else { + if rupost2.Data.(*model.Post).IsPinned != false { + t.Fatal("unpinning a post should be idempotent") + } + } +} |