From eb027c0d3bcd473db17ef6f9c96545b9406b3636 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 5 Dec 2017 17:34:10 -0600 Subject: make slack attachments gobable (#7948) --- plugin/rpcplugin/api.go | 5 +++++ plugin/rpcplugin/api_test.go | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'plugin') diff --git a/plugin/rpcplugin/api.go b/plugin/rpcplugin/api.go index fb3517ae2..76c6e3039 100644 --- a/plugin/rpcplugin/api.go +++ b/plugin/rpcplugin/api.go @@ -4,6 +4,7 @@ package rpcplugin import ( + "encoding/gob" "encoding/json" "io" "net/http" @@ -582,3 +583,7 @@ func ConnectAPI(conn io.ReadWriteCloser, muxer *Muxer) *RemoteAPI { return remoteApi } + +func init() { + gob.Register([]*model.SlackAttachment{}) +} diff --git a/plugin/rpcplugin/api_test.go b/plugin/rpcplugin/api_test.go index 8a36ef4f6..f9e474d4a 100644 --- a/plugin/rpcplugin/api_test.go +++ b/plugin/rpcplugin/api_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/plugin" @@ -70,6 +71,11 @@ 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) { @@ -192,9 +198,9 @@ func TestAPI(t *testing.T) { return p, nil }).Once() post, err := remote.CreatePost(testPost) + require.Nil(t, err) assert.NotEmpty(t, post.Id) assert.Equal(t, testPost.Message, post.Message) - assert.Nil(t, err) api.On("DeletePost", "thepostid").Return(nil).Once() assert.Nil(t, remote.DeletePost("thepostid")) -- cgit v1.2.3-1-g7c22