diff options
Diffstat (limited to 'store/sql_preference_store_test.go')
-rw-r--r-- | store/sql_preference_store_test.go | 41 |
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) +} |