PLT-8131 (part2) Add plugin key value store support (#7902)

* Add plugin key value store support

* Add localization strings

* Updates per feedback
This commit is contained in:
Joram Wilander
2017-11-27 17:23:35 -05:00
committed by GitHub
parent e85ec38301
commit 6176bcff69
22 changed files with 888 additions and 230 deletions

View File

@@ -12,9 +12,15 @@ import (
type API struct {
mock.Mock
Store *KeyValueStore
}
type KeyValueStore struct {
mock.Mock
}
var _ plugin.API = (*API)(nil)
var _ plugin.KeyValueStore = (*KeyValueStore)(nil)
func (m *API) LoadPluginConfiguration(dest interface{}) error {
return m.Called(dest).Error(0)
@@ -235,3 +241,35 @@ func (m *API) UpdatePost(post *model.Post) (*model.Post, *model.AppError) {
err, _ := ret.Get(1).(*model.AppError)
return postOut, err
}
func (m *API) KeyValueStore() plugin.KeyValueStore {
return m.Store
}
func (m *KeyValueStore) Set(key string, value []byte) *model.AppError {
ret := m.Called(key, value)
if f, ok := ret.Get(0).(func(string, []byte) *model.AppError); ok {
return f(key, value)
}
err, _ := ret.Get(0).(*model.AppError)
return err
}
func (m *KeyValueStore) Get(key string) ([]byte, *model.AppError) {
ret := m.Called(key)
if f, ok := ret.Get(0).(func(string) ([]byte, *model.AppError)); ok {
return f(key)
}
psv, _ := ret.Get(0).([]byte)
err, _ := ret.Get(1).(*model.AppError)
return psv, err
}
func (m *KeyValueStore) Delete(key string) *model.AppError {
ret := m.Called(key)
if f, ok := ret.Get(0).(func(string) *model.AppError); ok {
return f(key)
}
err, _ := ret.Get(0).(*model.AppError)
return err
}