// SetCharm adds and removes charms in s. The affected charm is identified by // charmURL, which must be revisioned. If bundle is nil, the charm will be // removed; otherwise, it will be stored. It is an error to store a bundle // under a charmURL that does not share its name and revision. func (s *MockCharmStore) SetCharm(charmURL *charm.URL, bundle *charm.Bundle) error { base := charmURL.WithRevision(-1).String() if charmURL.Revision < 0 { return fmt.Errorf("bad charm url revision") } if bundle == nil { delete(s.charms[base], charmURL.Revision) return nil } bundleRev := bundle.Revision() bundleName := bundle.Meta().Name if bundleName != charmURL.Name || bundleRev != charmURL.Revision { return fmt.Errorf("charm url %s mismatch with bundle %s-%d", charmURL, bundleName, bundleRev) } if _, found := s.charms[base]; !found { s.charms[base] = map[int]*charm.Bundle{} } s.charms[base][charmURL.Revision] = bundle return nil }
func assertCharm(c *C, bun *corecharm.Bundle, sch *state.Charm) { c.Assert(bun.Revision(), Equals, sch.Revision()) c.Assert(bun.Meta(), DeepEquals, sch.Meta()) c.Assert(bun.Config(), DeepEquals, sch.Config()) }