예제 #1
0
// NewLatestCharmHandler returns a LatestCharmHandler that uses the
// given Juju state.
func NewLatestCharmHandler(st *state.State) (charmrevisionupdater.LatestCharmHandler, error) {
	resources, err := st.Resources()
	if err != nil {
		return nil, errors.Trace(err)
	}
	handler := workers.NewLatestCharmHandler(resources)
	return handler, nil
}
예제 #2
0
func (s *LatestCharmHandlerSuite) TestSuccess(c *gc.C) {
	applicationID := names.NewApplicationTag("a-application")
	info := charmstore.CharmInfo{
		OriginalURL:    &charm.URL{},
		Timestamp:      time.Now().UTC(),
		LatestRevision: 2,
		LatestResources: []charmresource.Resource{
			resourcetesting.NewCharmResource(c, "spam", "<some data>"),
		},
	}
	handler := workers.NewLatestCharmHandler(s.store)

	err := handler.HandleLatest(applicationID, info)
	c.Assert(err, jc.ErrorIsNil)

	s.stub.CheckCallNames(c, "SetCharmStoreResources")
	s.stub.CheckCall(c, 0, "SetCharmStoreResources", "a-application", info.LatestResources, info.Timestamp)
}