func (api *Api) pluginUnsubsribe(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, err := account.FindPluginByNameAndService(mux.Vars(r)["plugin_name"], *service) if err != nil { handleError(rw, err) return } if err = plugin.Delete(); err != nil { handleError(rw, err) return } Ok(rw, plugin) }
func (s *S) TestFindPluginByNameAndService(c *C) { err := pluginConfig.Save(service) t, err := account.FindPluginByNameAndService(pluginConfig.Name, service) c.Check(t, Not(IsNil)) c.Check(err, IsNil) defer service.Delete(owner) }
func (s *S) TestFindPluginByNameAndServiceNotFound(c *C) { t, err := account.FindPluginByNameAndService("not-found", service) c.Check(t, IsNil) _, ok := err.(errors.NotFoundError) c.Assert(ok, Equals, true) }