summaryrefslogtreecommitdiffstats
path: root/api4/context_test.go
diff options
context:
space:
mode:
authorPoornima <mpoornima@users.noreply.github.com>2017-03-12 04:10:56 +0530
committerenahum <nahumhbl@gmail.com>2017-03-11 19:40:56 -0300
commit482a0fb5fc248b1ec61db35299dc3e6d963ad5ab (patch)
tree1f957f78b3a053366ca20fbcff8b274ea5eac4a0 /api4/context_test.go
parent11f1859de12be22726a93bb0fd201f3d692022a0 (diff)
downloadchat-482a0fb5fc248b1ec61db35299dc3e6d963ad5ab.tar.gz
chat-482a0fb5fc248b1ec61db35299dc3e6d963ad5ab.tar.bz2
chat-482a0fb5fc248b1ec61db35299dc3e6d963ad5ab.zip
Adding functionality to get & delete incoming webhooks (#5648)
Diffstat (limited to 'api4/context_test.go')
-rw-r--r--api4/context_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/api4/context_test.go b/api4/context_test.go
new file mode 100644
index 000000000..302b7b24b
--- /dev/null
+++ b/api4/context_test.go
@@ -0,0 +1,31 @@
+package api4
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRequireHookId(t *testing.T) {
+ c := &Context{}
+ t.Run("WhenHookIdIsValid", func(t *testing.T) {
+ c.Params = &ApiParams{HookId: "abcdefghijklmnopqrstuvwxyz"}
+ c.RequireHookId()
+
+ if c.Err != nil {
+ t.Fatal("Hook Id is Valid. Should not have set error in context")
+ }
+ })
+
+ t.Run("WhenHookIdIsInvalid", func(t *testing.T) {
+ c.Params = &ApiParams{HookId: "abc"}
+ c.RequireHookId()
+
+ if c.Err == nil {
+ t.Fatal("Should have set Error in context")
+ }
+
+ if c.Err.StatusCode != http.StatusBadRequest {
+ t.Fatal("Should have set status as 400")
+ }
+ })
+}