[MM-15296] Migrate "Preference.Save" to Sync by default (#10866)

* response format changes

* Generated mocks
Fixed all references of Preferences.Save

* Remove old code from store.go (incorrect merge)

* Review change - Add validations on count and error

* Review change - return from root level

* Review change - return 0 as nil value for int

* fix initialisation of err in preference_store
Этот коммит содержится в:
Ishank Gulati
2019-05-26 18:36:33 +05:30
коммит произвёл Jesús Espino
родитель c05cf5b033
Коммит fb6c1debf0
15 изменённых файлов: 150 добавлений и 86 удалений

Просмотреть файл

@@ -115,12 +115,14 @@ func TestCheckPendingNotifications(t *testing.T) {
channelMember.LastViewedAt = 9999999
store.Must(th.App.Srv.Store.Channel().UpdateMember(channelMember))
store.Must(th.App.Srv.Store.Preference().Save(&model.Preferences{{
count, err := th.App.Srv.Store.Preference().Save(&model.Preferences{{
UserId: th.BasicUser.Id,
Category: model.PREFERENCE_CATEGORY_NOTIFICATIONS,
Name: model.PREFERENCE_NAME_EMAIL_INTERVAL,
Value: "60",
}}))
}})
require.Nil(t, err)
require.Equal(t, 1, count)
// test that notifications aren't sent before interval
job.checkPendingNotifications(time.Unix(10001, 0), func(string, []*batchedNotification) {})
@@ -256,12 +258,14 @@ func TestCheckPendingNotificationsCantParseInterval(t *testing.T) {
store.Must(th.App.Srv.Store.Channel().UpdateMember(channelMember))
// preference value is not an integer, so we'll fall back to the default 15min value
store.Must(th.App.Srv.Store.Preference().Save(&model.Preferences{{
count, err := th.App.Srv.Store.Preference().Save(&model.Preferences{{
UserId: th.BasicUser.Id,
Category: model.PREFERENCE_CATEGORY_NOTIFICATIONS,
Name: model.PREFERENCE_NAME_EMAIL_INTERVAL,
Value: "notAnIntegerValue",
}}))
}})
require.Nil(t, err)
require.Equal(t, 1, count)
job.pendingNotifications[th.BasicUser.Id] = []*batchedNotification{
{