summaryrefslogtreecommitdiffstats
path: root/model/command_response_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/command_response_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/command_response_test.go')
-rw-r--r--model/command_response_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/model/command_response_test.go b/model/command_response_test.go
index b57a77608..df478ff2c 100644
--- a/model/command_response_test.go
+++ b/model/command_response_test.go
@@ -82,3 +82,17 @@ func TestCommandResponseFromJson(t *testing.T) {
t.Fatal("should've received correct second attachment value")
}
}
+
+func TestCommandResponseNullArrayItems(t *testing.T) {
+ payload := `{"attachments":[{"fields":[{"title":"foo","value":"bar","short":true}, null]}, null]}`
+ cr := CommandResponseFromJson(strings.NewReader(payload))
+ if cr == nil {
+ t.Fatal("CommandResponse should not be nil")
+ }
+ if len(cr.Attachments) != 1 {
+ t.Fatalf("expected one attachment")
+ }
+ if len(cr.Attachments[0].Fields) != 1 {
+ t.Fatalf("expected one field")
+ }
+}