diff options
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") + } + } +} |