summaryrefslogtreecommitdiffstats
path: root/api/post_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'api/post_test.go')
-rw-r--r--api/post_test.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/api/post_test.go b/api/post_test.go
index 29fe63ddc..2a2a9f41b 100644
--- a/api/post_test.go
+++ b/api/post_test.go
@@ -924,3 +924,38 @@ func TestGetOutOfChannelMentions(t *testing.T) {
t.Fatalf("getOutOfChannelMentions returned %v when two users on a different team were mentioned", mentioned)
}
}
+
+func TestGetFlaggedPosts(t *testing.T) {
+ th := Setup().InitBasic()
+ Client := th.BasicClient
+ user1 := th.BasicUser
+ post1 := th.BasicPost
+
+ preferences := &model.Preferences{
+ {
+ UserId: user1.Id,
+ Category: model.PREFERENCE_CATEGORY_FLAGGED_POST,
+ Name: post1.Id,
+ Value: "true",
+ },
+ }
+ Client.Must(Client.SetPreferences(preferences))
+
+ r1 := Client.Must(Client.GetFlaggedPosts(0, 2)).Data.(*model.PostList)
+
+ if len(r1.Order) == 0 {
+ t.Fatal("should have gotten a flagged post")
+ }
+
+ if _, ok := r1.Posts[post1.Id]; !ok {
+ t.Fatal("missing flagged post")
+ }
+
+ Client.DeletePreferences(preferences)
+
+ r2 := Client.Must(Client.GetFlaggedPosts(0, 2)).Data.(*model.PostList)
+
+ if len(r2.Order) != 0 {
+ t.Fatal("should not have gotten a flagged post")
+ }
+}