MM-8602: KV Store Json helper tweaks (#11502)

* move kv helpers to helpers_kv*.go

* change KVGetJSON return signature

Return a boolean and an error, to clearly indicate if no value was found and thus no value unmarshalled into the target interface.

Also fix an issue with CompareAndSet to allow an oldValue of nil (i.e.
expected to be unset).

* add missing license

* tweak documentation

* document KVSetWithExpiryJSON minimum version
Этот коммит содержится в:
Jesse Hallam
2019-07-05 17:33:39 -03:00
коммит произвёл GitHub
родитель c34942afec
Коммит 620d941b6e
7 изменённых файлов: 311 добавлений и 244 удалений

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

@@ -55,17 +55,24 @@ func (_m *Helpers) KVCompareAndSetJSON(key string, oldValue interface{}, newValu
}
// KVGetJSON provides a mock function with given fields: key, value
func (_m *Helpers) KVGetJSON(key string, value interface{}) error {
func (_m *Helpers) KVGetJSON(key string, value interface{}) (bool, error) {
ret := _m.Called(key, value)
var r0 error
if rf, ok := ret.Get(0).(func(string, interface{}) error); ok {
var r0 bool
if rf, ok := ret.Get(0).(func(string, interface{}) bool); ok {
r0 = rf(key, value)
} else {
r0 = ret.Error(0)
r0 = ret.Get(0).(bool)
}
return r0
var r1 error
if rf, ok := ret.Get(1).(func(string, interface{}) error); ok {
r1 = rf(key, value)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// KVSetJSON provides a mock function with given fields: key, value