diff options
author | Chris <ccbrown112@gmail.com> | 2017-07-12 06:43:07 -0700 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-07-12 09:43:07 -0400 |
commit | 9ee7f661c76d7ef07ac03772a7cf0394217203f3 (patch) | |
tree | 1dc5784a56f8fd39f43349425c24555d0389e257 /model/slack_attachment_test.go | |
parent | 83d53ea98cf5486f89bd4280b6b5ef835da4fd22 (diff) | |
download | chat-9ee7f661c76d7ef07ac03772a7cf0394217203f3.tar.gz chat-9ee7f661c76d7ef07ac03772a7cf0394217203f3.tar.bz2 chat-9ee7f661c76d7ef07ac03772a7cf0394217203f3.zip |
PLT-7077: ignore null array items in slack attachments (#6904)
* ignore null array items in incoming webhooks / command responses
* consolidate code, process announcements in command response as well
* make a bit more idiomatic, add tests
* add missing file
Diffstat (limited to 'model/slack_attachment_test.go')
-rw-r--r-- | model/slack_attachment_test.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/model/slack_attachment_test.go b/model/slack_attachment_test.go new file mode 100644 index 000000000..ff4df888f --- /dev/null +++ b/model/slack_attachment_test.go @@ -0,0 +1,38 @@ +package model + +import ( + "testing" +) + +func TestExpandAnnouncement(t *testing.T) { + if ExpandAnnouncement("<!channel> foo <!channel>") != "@channel foo @channel" { + t.Fail() + } +} + +func TestSlackAnnouncementProcess(t *testing.T) { + attachments := SlackAttachments{ + { + Pretext: "<!channel> pretext", + Text: "<!channel> text", + Title: "<!channel> title", + Fields: []*SlackAttachmentField{ + { + Title: "foo", + Value: "<!channel> bar", + Short: true, + }, nil, + }, + }, nil, + } + attachments.Process() + if len(attachments) != 1 || len(attachments[0].Fields) != 1 { + t.Fail() + } + if attachments[0].Pretext != "@channel pretext" || + attachments[0].Text != "@channel text" || + attachments[0].Title != "@channel title" || + attachments[0].Fields[0].Value != "@channel bar" { + t.Fail() + } +} |