summaryrefslogtreecommitdiffstats
path: root/plugin/rpcplugin/api_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/rpcplugin/api_test.go')
-rw-r--r--plugin/rpcplugin/api_test.go18
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)
})
}