Пример #1
0
func (api *Api) pluginSubsribe(rw http.ResponseWriter, r *http.Request, user *account.User) {
	service, err := account.FindServiceBySubdomain(mux.Vars(r)["subdomain"])
	if err != nil {
		handleError(rw, err)
		return
	}

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

	plugin := account.Plugin{}
	if err := json.NewDecoder(r.Body).Decode(&plugin); err != nil {
		handleError(rw, errors.ErrBadRequest)
		return
	}

	err = plugin.Save(*service)
	if err != nil {
		handleError(rw, err)
		return
	}

	Ok(rw, plugin)
}
Пример #2
0
func (s *S) TestSavePluginWithoutRequiredFields(c *C) {
	pluginConfig := account.Plugin{}
	err := pluginConfig.Save(service)
	_, ok := err.(errors.ValidationError)
	c.Assert(ok, Equals, true)
}