[MM-20353] Change KVSetWithOptions to accept a byte slice (#13213)
* Drop EncodeJSON from PluginKVSetOptions * Add unit tests for KVSetWithOptions with nil values
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3543fcce6c
Коммит
d0d6ce0a70
@@ -148,7 +148,7 @@ func (ps SqlPluginStore) CompareAndDelete(kv *model.PluginKeyValue, oldValue []b
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (ps SqlPluginStore) SetWithOptions(pluginId string, key string, value interface{}, opt model.PluginKVSetOptions) (bool, *model.AppError) {
|
||||
func (ps SqlPluginStore) SetWithOptions(pluginId string, key string, value []byte, opt model.PluginKVSetOptions) (bool, *model.AppError) {
|
||||
if err := opt.IsValid(); err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -159,13 +159,7 @@ func (ps SqlPluginStore) SetWithOptions(pluginId string, key string, value inter
|
||||
}
|
||||
|
||||
if opt.Atomic {
|
||||
var serializedOldValue []byte
|
||||
serializedOldValue, err = opt.GetOldValueSerialized()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return ps.CompareAndSet(kv, serializedOldValue)
|
||||
return ps.CompareAndSet(kv, opt.OldValue)
|
||||
}
|
||||
|
||||
savedKv, err := ps.SaveOrUpdate(kv)
|
||||
|
||||
@@ -531,7 +531,7 @@ type PluginStore interface {
|
||||
SaveOrUpdate(keyVal *model.PluginKeyValue) (*model.PluginKeyValue, *model.AppError)
|
||||
CompareAndSet(keyVal *model.PluginKeyValue, oldValue []byte) (bool, *model.AppError)
|
||||
CompareAndDelete(keyVal *model.PluginKeyValue, oldValue []byte) (bool, *model.AppError)
|
||||
SetWithOptions(pluginId string, key string, value interface{}, options model.PluginKVSetOptions) (bool, *model.AppError)
|
||||
SetWithOptions(pluginId string, key string, value []byte, options model.PluginKVSetOptions) (bool, *model.AppError)
|
||||
Get(pluginId, key string) (*model.PluginKeyValue, *model.AppError)
|
||||
Delete(pluginId, key string) *model.AppError
|
||||
DeleteAllForPlugin(PluginId string) *model.AppError
|
||||
|
||||
@@ -184,18 +184,18 @@ func (_m *PluginStore) SaveOrUpdate(keyVal *model.PluginKeyValue) (*model.Plugin
|
||||
}
|
||||
|
||||
// SetWithOptions provides a mock function with given fields: pluginId, key, value, options
|
||||
func (_m *PluginStore) SetWithOptions(pluginId string, key string, value interface{}, options model.PluginKVSetOptions) (bool, *model.AppError) {
|
||||
func (_m *PluginStore) SetWithOptions(pluginId string, key string, value []byte, options model.PluginKVSetOptions) (bool, *model.AppError) {
|
||||
ret := _m.Called(pluginId, key, value, options)
|
||||
|
||||
var r0 bool
|
||||
if rf, ok := ret.Get(0).(func(string, string, interface{}, model.PluginKVSetOptions) bool); ok {
|
||||
if rf, ok := ret.Get(0).(func(string, string, []byte, model.PluginKVSetOptions) bool); ok {
|
||||
r0 = rf(pluginId, key, value, options)
|
||||
} else {
|
||||
r0 = ret.Get(0).(bool)
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string, string, interface{}, model.PluginKVSetOptions) *model.AppError); ok {
|
||||
if rf, ok := ret.Get(1).(func(string, string, []byte, model.PluginKVSetOptions) *model.AppError); ok {
|
||||
r1 = rf(pluginId, key, value, options)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user