From 482a0fb5fc248b1ec61db35299dc3e6d963ad5ab Mon Sep 17 00:00:00 2001 From: Poornima Date: Sun, 12 Mar 2017 04:10:56 +0530 Subject: Adding functionality to get & delete incoming webhooks (#5648) --- api4/context_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 api4/context_test.go (limited to 'api4/context_test.go') 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") + } + }) +} -- cgit v1.2.3-1-g7c22