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
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
83d53ea98c
Коммит
9ee7f661c7
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user