func (s *CharmSuite) TestRead(c *gc.C) { bPath := charmtesting.Charms.BundlePath(c.MkDir(), "dummy") ch, err := charm.Read(bPath) c.Assert(err, gc.IsNil) c.Assert(ch.Meta().Name, gc.Equals, "dummy") dPath := charmtesting.Charms.DirPath("dummy") ch, err = charm.Read(dPath) c.Assert(err, gc.IsNil) c.Assert(ch.Meta().Name, gc.Equals, "dummy") }
// validateAction validates the given Action params against the spec defined // for the charm. func (u *Uniter) validateAction(name string, params map[string]interface{}) (bool, error) { ch, err := corecharm.Read(u.charmPath) if err != nil { return false, err } // Note that ch.Actions() will never be nil, rather an empty struct. actionSpecs := ch.Actions() spec, ok := actionSpecs.ActionSpecs[name] if !ok { return false, fmt.Errorf("no spec was defined for action %q", name) } return spec.ValidateParams(params) }