Ejemplo n.º 1
0
Archivo: manifold.go Proyecto: bac/juju
func newWorker(a agent.Agent, apiCaller base.APICaller) (worker.Worker, error) {
	st := apiagent.NewState(apiCaller)
	isMM, err := isModelManager(a, st)
	if err != nil {
		return nil, errors.Trace(err)
	}
	if !isMM {
		return nil, dependency.ErrMissing
	}

	// 4 times a day seems a decent enough amount of checks.
	checkerParams := VersionCheckerParams{
		CheckInterval: time.Hour * 6,
	}
	return New(agenttools.NewFacade(apiCaller), &checkerParams), nil
}
Ejemplo n.º 2
0
func (s *AgentToolsSuite) TestUpdateToolsVersion(c *gc.C) {
	called := false
	apiCaller := testing.APICallerFunc(
		func(objType string,
			version int,
			id, request string,
			a, result interface{},
		) error {
			called = true
			c.Check(objType, gc.Equals, "AgentTools")
			c.Check(id, gc.Equals, "")
			c.Check(request, gc.Equals, "UpdateToolsAvailable")

			c.Assert(a, gc.IsNil)
			return nil
		})
	client := agenttools.NewFacade(apiCaller)
	err := client.UpdateToolsVersion()
	c.Check(err, jc.ErrorIsNil)
	c.Assert(called, jc.IsTrue)
}