Change the implementation of GetAll() in preference_store.go to ret… (#10926)

* Change the implementation of GetAll() in `preference_store.go` to return an
object from `model` and a *model.AppError.
Change the Interface in `store.go` to accomodate for the change
Change the test that called the GetAll() function

* Rename the result variable to preferences so it makes more sense.
Use assertions to keep the test consistent

* Generate the correct mocks after the code changes

* Remove redundant conditions

* Address govet errors

* Resolve conflicts with master's new changes

* Fix Save() function according to the new changes in master (Got
overwritten with the previous commit)

* Change the assertions to have the same format as commit 2d97f01
Этот коммит содержится в:
Giorgos Christos Dimitriou
2019-06-03 12:25:04 +01:00
коммит произвёл Dean Whillier
родитель d1f81842a5
Коммит 2e79ae9636
5 изменённых файлов: 58 добавлений и 53 удалений

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

@@ -192,22 +192,19 @@ func (s SqlPreferenceStore) GetCategory(userId string, category string) (model.P
}
func (s SqlPreferenceStore) GetAll(userId string) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
var preferences model.Preferences
func (s SqlPreferenceStore) GetAll(userId string) (model.Preferences, *model.AppError) {
var preferences model.Preferences
if _, err := s.GetReplica().Select(&preferences,
`SELECT
if _, err := s.GetReplica().Select(&preferences,
`SELECT
*
FROM
Preferences
WHERE
UserId = :UserId`, map[string]interface{}{"UserId": userId}); err != nil {
result.Err = model.NewAppError("SqlPreferenceStore.GetAll", "store.sql_preference.get_all.app_error", nil, err.Error(), http.StatusInternalServerError)
} else {
result.Data = preferences
}
})
return nil, model.NewAppError("SqlPreferenceStore.GetAll", "store.sql_preference.get_all.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return preferences, nil
}
func (s SqlPreferenceStore) PermanentDeleteByUser(userId string) *model.AppError {