mirror of
https://github.com/mattermost/mattermost.git
synced 2026-02-23 18:04:25 -05:00
31 lines
621 B
Go
31 lines
621 B
Go
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")
|
|
}
|
|
})
|
|
}
|