diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-11-27 17:23:35 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-27 17:23:35 -0500 |
commit | 6176bcff6977bda71f4fde10a52dde6d7d7ceb9a (patch) | |
tree | b4a4a22879f4b88ffc4fb59f46ca69d441569ddd /plugin/rpcplugin/api_test.go | |
parent | e85ec3830164ffdfbe8fd5696ab99446b38a01ef (diff) | |
download | chat-6176bcff6977bda71f4fde10a52dde6d7d7ceb9a.tar.gz chat-6176bcff6977bda71f4fde10a52dde6d7d7ceb9a.tar.bz2 chat-6176bcff6977bda71f4fde10a52dde6d7d7ceb9a.zip |
PLT-8131 (part2) Add plugin key value store support (#7902)
* Add plugin key value store support
* Add localization strings
* Updates per feedback
Diffstat (limited to 'plugin/rpcplugin/api_test.go')
-rw-r--r-- | plugin/rpcplugin/api_test.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/plugin/rpcplugin/api_test.go b/plugin/rpcplugin/api_test.go index 080f2825f..0c7321162 100644 --- a/plugin/rpcplugin/api_test.go +++ b/plugin/rpcplugin/api_test.go @@ -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) }) } |