summaryrefslogtreecommitdiffstats
path: root/store/sql_preference_store_test.go
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2017-09-22 18:23:16 +0100
committerHarrison Healey <harrisonmhealey@gmail.com>2017-09-22 13:23:16 -0400
commite0d5703f721aafef1b55747cd09629860e86bfb4 (patch)
tree7b1555843f3577c8b804c47b1ebddb0dddcf2852 /store/sql_preference_store_test.go
parent8bef94d250906851d924c16fc5293bbdae75cb98 (diff)
downloadchat-e0d5703f721aafef1b55747cd09629860e86bfb4.tar.gz
chat-e0d5703f721aafef1b55747cd09629860e86bfb4.tar.bz2
chat-e0d5703f721aafef1b55747cd09629860e86bfb4.zip
PLT-7619: Cleanup flags in data retention. (#7501)
Diffstat (limited to 'store/sql_preference_store_test.go')
-rw-r--r--store/sql_preference_store_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/store/sql_preference_store_test.go b/store/sql_preference_store_test.go
index ac8097a9e..0c537bb49 100644
--- a/store/sql_preference_store_test.go
+++ b/store/sql_preference_store_test.go
@@ -6,6 +6,8 @@ package store
import (
"testing"
+ "github.com/stretchr/testify/assert"
+
"github.com/mattermost/mattermost-server/model"
)
@@ -473,3 +475,42 @@ func TestPreferenceDeleteCategoryAndName(t *testing.T) {
t.Fatal("should've returned no preferences")
}
}
+
+func TestPreferenceCleanupFlagsBatch(t *testing.T) {
+ Setup()
+
+ category := model.PREFERENCE_CATEGORY_FLAGGED_POST
+ userId := model.NewId()
+
+ o1 := &model.Post{}
+ o1.ChannelId = model.NewId()
+ o1.UserId = userId
+ o1.Message = "zz" + model.NewId() + "AAAAAAAAAAA"
+ o1.CreateAt = 1000
+ o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
+
+ preference1 := model.Preference{
+ UserId: userId,
+ Category: category,
+ Name: o1.Id,
+ Value: "true",
+ }
+
+ preference2 := model.Preference{
+ UserId: userId,
+ Category: category,
+ Name: model.NewId(),
+ Value: "true",
+ }
+
+ Must(store.Preference().Save(&model.Preferences{preference1, preference2}))
+
+ result := <-store.Preference().CleanupFlagsBatch(10000)
+ assert.Nil(t, result.Err)
+
+ result = <-store.Preference().Get(userId, category, preference1.Name)
+ assert.Nil(t, result.Err)
+
+ result = <-store.Preference().Get(userId, category, preference2.Name)
+ assert.NotNil(t, result.Err)
+}