示例#1
0
func (s *S) TestFindHookByName(c *C) {
	hook.Save(team)

	t, err := account.FindHookByName(hook.Name)
	c.Check(t, Not(IsNil))
	c.Check(err, IsNil)
	defer hook.Delete()
}
示例#2
0
func (api *Api) hookDelete(rw http.ResponseWriter, r *http.Request, user *account.User) {
	hook, err := account.FindHookByName(mux.Vars(r)["name"])
	if err != nil {
		handleError(rw, err)
		return
	}

	_, err = findTeamAndCheckUser(hook.Team, user)
	if err != nil {
		handleError(rw, err)
		return
	}

	if err = hook.Delete(); err != nil {
		handleError(rw, err)
		return
	}

	Ok(rw, hook)
}
示例#3
0
func (s *S) TestFindHookByNameNotFound(c *C) {
	t, err := account.FindHookByName("not-found")
	c.Check(t, IsNil)
	_, ok := err.(errors.NotFoundError)
	c.Assert(ok, Equals, true)
}