mirror of
https://github.com/mattermost/mattermost.git
synced 2026-09-24 16:05:00 +08:00
make slack attachments gobable (#7948)
This commit is contained in:
committed by
Christopher Speller
parent
7cefef6d21
commit
eb027c0d3b
@@ -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{})
|
||||
}
|
||||
|
||||
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user