[GH-10866] Preferrence.Save - Remove preference length return arg (#10962)

Этот коммит содержится в:
Ishank Gulati
2019-05-29 19:24:57 +05:30
коммит произвёл Harrison Healey
родитель 42ac975c0e
Коммит 3b25e09b99
15 изменённых файлов: 52 добавлений и 90 удалений

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

@@ -54,25 +54,25 @@ func (s SqlPreferenceStore) DeleteUnusedFeatures() {
s.GetMaster().Exec(sql, queryParams)
}
func (s SqlPreferenceStore) Save(preferences *model.Preferences) (int, *model.AppError) {
func (s SqlPreferenceStore) Save(preferences *model.Preferences) *model.AppError {
// wrap in a transaction so that if one fails, everything fails
transaction, err := s.GetMaster().Begin()
if err != nil {
return 0, model.NewAppError("SqlPreferenceStore.Save", "store.sql_preference.save.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError)
return model.NewAppError("SqlPreferenceStore.Save", "store.sql_preference.save.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError)
}
defer finalizeTransaction(transaction)
for _, preference := range *preferences {
if upsertResult := s.save(transaction, &preference); upsertResult.Err != nil {
return 0, upsertResult.Err
return upsertResult.Err
}
}
if err := transaction.Commit(); err != nil {
// don't need to rollback here since the transaction is already closed
return 0, model.NewAppError("SqlPreferenceStore.Save", "store.sql_preference.save.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError)
return model.NewAppError("SqlPreferenceStore.Save", "store.sql_preference.save.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return len(*preferences), nil
return nil
}
func (s SqlPreferenceStore) save(transaction *gorp.Transaction, preference *model.Preference) store.StoreResult {

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

@@ -52,9 +52,8 @@ func TestDeleteUnusedFeatures(t *testing.T) {
},
}
count, err := ss.Preference().Save(&features)
err := ss.Preference().Save(&features)
require.Nil(t, err)
require.Equal(t, 4, count)
ss.Preference().(*SqlPreferenceStore).DeleteUnusedFeatures()