summaryrefslogtreecommitdiffstats
path: root/plugin
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2018-03-06 20:01:18 -0600
committerDerrick Anderson <derrick@andersonwebstudio.com>2018-03-06 21:01:18 -0500
commita434fe763790e8089e5ad0b0eccceddd937e10b4 (patch)
treefb8340b2e76d1ea35b234d815106bb393bda6c3e /plugin
parenta3320e0ce31352e9279b87a9bed31b5bdfd8ad91 (diff)
downloadchat-a434fe763790e8089e5ad0b0eccceddd937e10b4.tar.gz
chat-a434fe763790e8089e5ad0b0eccceddd937e10b4.tar.bz2
chat-a434fe763790e8089e5ad0b0eccceddd937e10b4.zip
register additional gob types to support arrays and dicts in post props (#8412)
Diffstat (limited to 'plugin')
-rw-r--r--plugin/rpcplugin/api.go2
-rw-r--r--plugin/rpcplugin/api_test.go43
2 files changed, 40 insertions, 5 deletions
diff --git a/plugin/rpcplugin/api.go b/plugin/rpcplugin/api.go
index 5b5b11a62..d87f65b55 100644
--- a/plugin/rpcplugin/api.go
+++ b/plugin/rpcplugin/api.go
@@ -610,4 +610,6 @@ func ConnectAPI(conn io.ReadWriteCloser, muxer *Muxer) *RemoteAPI {
func init() {
gob.Register([]*model.SlackAttachment{})
+ gob.Register([]interface{}{})
+ gob.Register(map[string]interface{}{})
}
diff --git a/plugin/rpcplugin/api_test.go b/plugin/rpcplugin/api_test.go
index 145ec9005..7fe7a0ff9 100644
--- a/plugin/rpcplugin/api_test.go
+++ b/plugin/rpcplugin/api_test.go
@@ -72,11 +72,6 @@ func TestAPI(t *testing.T) {
testPost := &model.Post{
Message: "hello",
- Props: map[string]interface{}{
- "attachments": []*model.SlackAttachment{
- &model.SlackAttachment{},
- },
- },
}
testAPIRPC(&api, func(remote plugin.API) {
@@ -244,3 +239,41 @@ func TestAPI(t *testing.T) {
assert.Nil(t, err)
})
}
+
+func TestAPI_GobRegistration(t *testing.T) {
+ keyValueStore := &plugintest.KeyValueStore{}
+ api := plugintest.API{Store: keyValueStore}
+ defer api.AssertExpectations(t)
+
+ testAPIRPC(&api, func(remote plugin.API) {
+ api.On("CreatePost", mock.AnythingOfType("*model.Post")).Return(func(p *model.Post) (*model.Post, *model.AppError) {
+ p.Id = "thepostid"
+ return p, nil
+ }).Once()
+ _, err := remote.CreatePost(&model.Post{
+ Message: "hello",
+ Props: map[string]interface{}{
+ "attachments": []*model.SlackAttachment{
+ &model.SlackAttachment{
+ Actions: []*model.PostAction{
+ &model.PostAction{
+ Integration: &model.PostActionIntegration{
+ Context: map[string]interface{}{
+ "foo": "bar",
+ "foos": []interface{}{"bar", "baz", 1, 2},
+ "foo_map": map[string]interface{}{
+ "1": "bar",
+ "2": 2,
+ },
+ },
+ },
+ },
+ },
+ Timestamp: 1,
+ },
+ },
+ },
+ })
+ require.Nil(t, err)
+ })
+}