make slack attachments gobable (#7948)

Этот коммит содержится в:
Chris
2017-12-05 17:34:10 -06:00
коммит произвёл Christopher Speller
родитель 7cefef6d21
Коммит eb027c0d3b
2 изменённых файлов: 12 добавлений и 1 удалений

Просмотреть файл

@@ -4,6 +4,7 @@
package rpcplugin package rpcplugin
import ( import (
"encoding/gob"
"encoding/json" "encoding/json"
"io" "io"
"net/http" "net/http"
@@ -582,3 +583,7 @@ func ConnectAPI(conn io.ReadWriteCloser, muxer *Muxer) *RemoteAPI {
return remoteApi return remoteApi
} }
func init() {
gob.Register([]*model.SlackAttachment{})
}

Просмотреть файл

@@ -8,6 +8,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock" "github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/plugin" "github.com/mattermost/mattermost-server/plugin"
@@ -70,6 +71,11 @@ func TestAPI(t *testing.T) {
testPost := &model.Post{ testPost := &model.Post{
Message: "hello", Message: "hello",
Props: map[string]interface{}{
"attachments": []*model.SlackAttachment{
&model.SlackAttachment{},
},
},
} }
testAPIRPC(&api, func(remote plugin.API) { testAPIRPC(&api, func(remote plugin.API) {
@@ -192,9 +198,9 @@ func TestAPI(t *testing.T) {
return p, nil return p, nil
}).Once() }).Once()
post, err := remote.CreatePost(testPost) post, err := remote.CreatePost(testPost)
require.Nil(t, err)
assert.NotEmpty(t, post.Id) assert.NotEmpty(t, post.Id)
assert.Equal(t, testPost.Message, post.Message) assert.Equal(t, testPost.Message, post.Message)
assert.Nil(t, err)
api.On("DeletePost", "thepostid").Return(nil).Once() api.On("DeletePost", "thepostid").Return(nil).Once()
assert.Nil(t, remote.DeletePost("thepostid")) assert.Nil(t, remote.DeletePost("thepostid"))