summaryrefslogtreecommitdiffstats
path: root/model/incoming_webhook_test.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-07-12 06:43:07 -0700
committerHarrison Healey <harrisonmhealey@gmail.com>2017-07-12 09:43:07 -0400
commit9ee7f661c76d7ef07ac03772a7cf0394217203f3 (patch)
tree1dc5784a56f8fd39f43349425c24555d0389e257 /model/incoming_webhook_test.go
parent83d53ea98cf5486f89bd4280b6b5ef835da4fd22 (diff)
downloadchat-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/incoming_webhook_test.go')
-rw-r--r--model/incoming_webhook_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/model/incoming_webhook_test.go b/model/incoming_webhook_test.go
index f6baca988..36f8ed6e6 100644
--- a/model/incoming_webhook_test.go
+++ b/model/incoming_webhook_test.go
@@ -230,3 +230,17 @@ func TestIncomingWebhookRequestFromJson(t *testing.T) {
}
}
}
+
+func TestIncomingWebhookNullArrayItems(t *testing.T) {
+ payload := `{"attachments":[{"fields":[{"title":"foo","value":"bar","short":true}, null]}, null]}`
+ iwr := IncomingWebhookRequestFromJson(strings.NewReader(payload))
+ if iwr == nil {
+ t.Fatal("IncomingWebhookRequest should not be nil")
+ }
+ if len(iwr.Attachments) != 1 {
+ t.Fatalf("expected one attachment")
+ }
+ if len(iwr.Attachments[0].Fields) != 1 {
+ t.Fatalf("expected one field")
+ }
+}