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

* Add plugin key value store support

* Add localization strings

* Updates per feedback
Этот коммит содержится в:
Joram Wilander
2017-11-27 17:23:35 -05:00
коммит произвёл GitHub
родитель e85ec38301
Коммит 6176bcff69
22 изменённых файлов: 888 добавлений и 230 удалений

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

@@ -34,7 +34,8 @@ func testAPIRPC(api plugin.API, f func(plugin.API)) {
}
func TestAPI(t *testing.T) {
var api plugintest.API
keyValueStore := &plugintest.KeyValueStore{}
api := plugintest.API{Store: keyValueStore}
defer api.AssertExpectations(t)
type Config struct {
@@ -199,5 +200,20 @@ func TestAPI(t *testing.T) {
post, err = remote.UpdatePost(testPost)
assert.Equal(t, testPost, post)
assert.Nil(t, err)
api.KeyValueStore().(*plugintest.KeyValueStore).On("Set", "thekey", []byte("thevalue")).Return(nil).Once()
err = remote.KeyValueStore().Set("thekey", []byte("thevalue"))
assert.Nil(t, err)
api.KeyValueStore().(*plugintest.KeyValueStore).On("Get", "thekey").Return(func(key string) ([]byte, *model.AppError) {
return []byte("thevalue"), nil
}).Once()
ret, err := remote.KeyValueStore().Get("thekey")
assert.Nil(t, err)
assert.Equal(t, []byte("thevalue"), ret)
api.KeyValueStore().(*plugintest.KeyValueStore).On("Delete", "thekey").Return(nil).Once()
err = remote.KeyValueStore().Delete("thekey")
assert.Nil(t, err)
})
}