func (s *charmSuite) TestInvalidCharmURLs(c *gc.C) { invalidURLs := []string{"", "local:~user/charm", // false: user on local "local:~user/series/charm", // false: user on local "local:~user/series/charm-1", // false: user on local "local:charm--2", // false: only -1 is a valid negative revision "blah:charm-2", // false: invalid schema "local:series/charm-01", // false: revision is funny } for _, url := range invalidURLs { c.Logf("Processing tag %q", url) c.Assert(names.IsValidCharm(url), jc.IsFalse) } }
// Validate checks the AuthorizationRequest for errors. func (s AuthorizationRequest) Validate() error { if !utils.IsValidUUIDString(s.EnvironmentUUID) { return errors.Errorf("invalid environment UUID: %q", s.EnvironmentUUID) } if s.ServiceName == "" { return errors.New("undefined service name") } if !names.IsValidService(s.ServiceName) { return errors.Errorf("invalid service name: %q", s.ServiceName) } if s.CharmURL == "" { return errors.New("undefined charm url") } if !names.IsValidCharm(s.CharmURL) { return errors.Errorf("invalid charm url: %q", s.CharmURL) } if s.PlanURL == "" { return errors.Errorf("undefined plan url") } return nil }
func (s *charmSuite) TestValidCharmURLs(c *gc.C) { for _, url := range validCharmURLs { c.Logf("Processing tag %q", url) c.Assert(names.IsValidCharm(url), jc.IsTrue) } }