summaryrefslogtreecommitdiffstats
path: root/app/plugin_test.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-11-27 17:23:35 -0500
committerGitHub <noreply@github.com>2017-11-27 17:23:35 -0500
commit6176bcff6977bda71f4fde10a52dde6d7d7ceb9a (patch)
treeb4a4a22879f4b88ffc4fb59f46ca69d441569ddd /app/plugin_test.go
parente85ec3830164ffdfbe8fd5696ab99446b38a01ef (diff)
downloadchat-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 'app/plugin_test.go')
-rw-r--r--app/plugin_test.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/app/plugin_test.go b/app/plugin_test.go
new file mode 100644
index 000000000..a9d872401
--- /dev/null
+++ b/app/plugin_test.go
@@ -0,0 +1,35 @@
+// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package app
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestPluginKeyValueStore(t *testing.T) {
+ th := Setup().InitBasic()
+ defer th.TearDown()
+
+ pluginId := "testpluginid"
+
+ assert.Nil(t, th.App.SetPluginKey(pluginId, "key", []byte("test")))
+ ret, err := th.App.GetPluginKey(pluginId, "key")
+ assert.Nil(t, err)
+ assert.Equal(t, []byte("test"), ret)
+
+ // Test inserting over existing entries
+ assert.Nil(t, th.App.SetPluginKey(pluginId, "key", []byte("test2")))
+
+ // Test getting non-existent key
+ ret, err = th.App.GetPluginKey(pluginId, "notakey")
+ assert.Nil(t, err)
+ assert.Nil(t, ret)
+
+ assert.Nil(t, th.App.DeletePluginKey(pluginId, "stringkey"))
+ assert.Nil(t, th.App.DeletePluginKey(pluginId, "intkey"))
+ assert.Nil(t, th.App.DeletePluginKey(pluginId, "postkey"))
+ assert.Nil(t, th.App.DeletePluginKey(pluginId, "notrealkey"))
+}