From 0d0734ac9845ef32c55ebf4c3185ba85065c5940 Mon Sep 17 00:00:00 2001 From: David Lu Date: Fri, 27 May 2016 08:35:55 -0700 Subject: Added duplicated trigger validation (#3124) --- api/webhook_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'api/webhook_test.go') diff --git a/api/webhook_test.go b/api/webhook_test.go index 1b13bb5d4..80ee8ad7d 100644 --- a/api/webhook_test.go +++ b/api/webhook_test.go @@ -262,6 +262,17 @@ func TestCreateOutgoingHook(t *testing.T) { t.Fatal("team ids didn't match") } + hook = &model.OutgoingWebhook{ChannelId: channel1.Id, TriggerWords: []string{"cats", "dogs"}, CallbackURLs: []string{"http://nowhere.com", "http://cats.com"}} + hook1 := &model.OutgoingWebhook{ChannelId: channel1.Id, TriggerWords: []string{"cats"}, CallbackURLs: []string{"http://nowhere.com"}} + + if _, err := Client.CreateOutgoingWebhook(hook); err != nil { + t.Fatal("multiple trigger words and urls failed") + } + + if _, err := Client.CreateOutgoingWebhook(hook1); err == nil { + t.Fatal("should have failed - duplicate trigger words and urls") + } + hook = &model.OutgoingWebhook{ChannelId: "junk", CallbackURLs: []string{"http://nowhere.com"}} if _, err := Client.CreateOutgoingWebhook(hook); err == nil { t.Fatal("should have failed - bad channel id") -- cgit v1.2.3-1-g7c22