From 6176bcff6977bda71f4fde10a52dde6d7d7ceb9a Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 27 Nov 2017 17:23:35 -0500 Subject: PLT-8131 (part2) Add plugin key value store support (#7902) * Add plugin key value store support * Add localization strings * Updates per feedback --- plugin/plugintest/api.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'plugin/plugintest') diff --git a/plugin/plugintest/api.go b/plugin/plugintest/api.go index c0e77648b..37052b4cf 100644 --- a/plugin/plugintest/api.go +++ b/plugin/plugintest/api.go @@ -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 +} -- cgit v1.2.3-1-g7c22