summaryrefslogtreecommitdiffstats
path: root/model/incoming_webhook_test.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2017-03-08 04:15:33 -0500
committerGeorge Goldberg <george@gberg.me>2017-03-08 09:15:33 +0000
commit5d62b3661bcf4b912e7809ca05082e364e2b34b1 (patch)
tree0221dc157810527bc98809489f03f29305bab008 /model/incoming_webhook_test.go
parentf3a266ee5d25bfff322acd3cc5eef91a6dce8954 (diff)
downloadchat-5d62b3661bcf4b912e7809ca05082e364e2b34b1.tar.gz
chat-5d62b3661bcf4b912e7809ca05082e364e2b34b1.tar.bz2
chat-5d62b3661bcf4b912e7809ca05082e364e2b34b1.zip
Added additional validation for slack attachment format on server (#5680)
Diffstat (limited to 'model/incoming_webhook_test.go')
-rw-r--r--model/incoming_webhook_test.go31
1 files changed, 15 insertions, 16 deletions
diff --git a/model/incoming_webhook_test.go b/model/incoming_webhook_test.go
index 8246b6c0a..46e5b6743 100644
--- a/model/incoming_webhook_test.go
+++ b/model/incoming_webhook_test.go
@@ -142,21 +142,20 @@ func TestIncomingWebhookRequestFromJson_Announcements(t *testing.T) {
t.Fatal("IncomingWebhookRequest should not be nil")
}
- attachments := iwr.Attachments.([]interface{})
- attachment := attachments[0].(map[string]interface{})
- if attachment["pretext"] != expected {
- t.Fatalf("Sample attachment pretext should be: %s, got: %s", expected, attachment["pretext"])
+ attachment := iwr.Attachments[0]
+ if attachment.Pretext != expected {
+ t.Fatalf("Sample attachment pretext should be:%s, got: %s", expected, attachment.Pretext)
}
- if attachment["text"] != expected {
- t.Fatalf("Sample attachment text should be: %s, got: %s", expected, attachment["text"])
+ if attachment.Text != expected {
+ t.Fatalf("Sample attachment text should be: %s, got: %s", expected, attachment.Text)
}
- if attachment["title"] != expected {
- t.Fatalf("Sample attachment title should be: %s, got: %s", expected, attachment["title"])
+ if attachment.Title != expected {
+ t.Fatalf("Sample attachment title should be: %s, got: %s", expected, attachment.Title)
}
- fields := attachment["fields"].([]interface{})
- field := fields[0].(map[string]interface{})
- if field["value"] != expected {
- t.Fatalf("Sample attachment field value should be: %s, got: %s", expected, field["value"])
+
+ field := attachment.Fields[0]
+ if field.Value != expected {
+ t.Fatalf("Sample attachment field value should be: %s, got: %s", expected, field.Value)
}
}
@@ -224,10 +223,10 @@ func TestIncomingWebhookRequestFromJson(t *testing.T) {
if iwr.Text != expected {
t.Fatalf("Sample %d text should be: %s, got: %s", i, expected, iwr.Text)
}
- attachments := iwr.Attachments.([]interface{})
- attachment := attachments[0].(map[string]interface{})
- if attachment["text"] != expected {
- t.Fatalf("Sample %d attachment text should be: %s, got: %s", i, expected, attachment["text"])
+
+ attachment := iwr.Attachments[0]
+ if attachment.Text != expected {
+ t.Fatalf("Sample %d attachment text should be: %s, got: %s", i, expected, attachment.Text)
}
}
}