Files
mattermost/web/context_test.go
Joram Wilander 47250c6629 Refactor context out of API packages (#8755)
* Refactor context out of API packages

* Update function names per feedback

* Move webhook handlers to web and fix web tests

* Move more webhook tests out of api package

* Fix static handler
2018-05-14 10:24:58 -04:00

32 lines
614 B
Go

package web
import (
"net/http"
"testing"
)
func TestRequireHookId(t *testing.T) {
c := &Context{}
t.Run("WhenHookIdIsValid", func(t *testing.T) {
c.Params = &Params{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 = &Params{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")
}
})
}