summaryrefslogtreecommitdiffstats
path: root/model/client4_test.go
diff options
context:
space:
mode:
authorDerrick Anderson <derrick@andersonwebstudio.com>2018-02-12 15:09:59 -0500
committerDerrick Anderson <derrick@andersonwebstudio.com>2018-02-12 15:09:59 -0500
commitefd620d6c80ddc1f015811ec58514e34ee0b501b (patch)
tree8fdcc1043aba1c9a66382b915f4e185ade1128fb /model/client4_test.go
parent87fb19b8279c86c72ffec623e55b80ce35b7d64f (diff)
parent1ae680aefae2deb1e9d07d7c2a1c863ec807a79f (diff)
downloadchat-efd620d6c80ddc1f015811ec58514e34ee0b501b.tar.gz
chat-efd620d6c80ddc1f015811ec58514e34ee0b501b.tar.bz2
chat-efd620d6c80ddc1f015811ec58514e34ee0b501b.zip
Merge branch 'release-4.7' into icu669
Diffstat (limited to 'model/client4_test.go')
-rw-r--r--model/client4_test.go58
1 files changed, 58 insertions, 0 deletions
diff --git a/model/client4_test.go b/model/client4_test.go
new file mode 100644
index 000000000..f7923fa8f
--- /dev/null
+++ b/model/client4_test.go
@@ -0,0 +1,58 @@
+// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package model
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+// https://github.com/mattermost/mattermost-server/issues/8205
+func TestClient4CreatePost(t *testing.T) {
+ post := &Post{
+ Props: map[string]interface{}{
+ "attachments": []*SlackAttachment{
+ &SlackAttachment{
+ Actions: []*PostAction{
+ &PostAction{
+ Integration: &PostActionIntegration{
+ Context: map[string]interface{}{
+ "foo": "bar",
+ },
+ URL: "http://foo.com",
+ },
+ Name: "Foo",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ attachments := PostFromJson(r.Body).Attachments()
+ assert.Equal(t, []*SlackAttachment{
+ &SlackAttachment{
+ Actions: []*PostAction{
+ &PostAction{
+ Integration: &PostActionIntegration{
+ Context: map[string]interface{}{
+ "foo": "bar",
+ },
+ URL: "http://foo.com",
+ },
+ Name: "Foo",
+ },
+ },
+ },
+ }, attachments)
+ }))
+
+ client := NewAPIv4Client(server.URL)
+ _, resp := client.CreatePost(post)
+ assert.Equal(t, http.StatusOK, resp.StatusCode)
+}