Exemple #1
0
func (*FacadeSuite) TestRunningActions(c *gc.C) {
	stub := &testing.Stub{}
	auth := agentAuth{
		machine: true,
	}
	backend := &mockBackend{
		stub: stub,
	}

	facade, err := machineactions.NewFacade(backend, nil, auth)
	c.Assert(err, jc.ErrorIsNil)

	stub.SetErrors(errors.New("boom"))
	results := facade.RunningActions(entities(
		"valid", // we will cause this one to err out
		"valid",
		"invalid",
		"unauthorized",
	))

	c.Assert(results, gc.DeepEquals, params.ActionsByReceivers{
		Actions: []params.ActionsByReceiver{{
			Receiver: "valid",
			Error:    common.ServerError(errors.New("boom")),
		}, {
			Receiver: "valid",
			Actions:  actions,
		}, {
			Error: common.ServerError(common.ErrBadId),
		}, {
			Receiver: "unauthorized",
			Error:    common.ServerError(common.ErrPerm),
		}},
	})
	stub.CheckCallNames(c, "TagToActionReceiverFn", "ConvertActions", "ConvertActions")
}
Exemple #2
0
func (*FacadeSuite) TestOtherAgent(c *gc.C) {
	facade, err := machineactions.NewFacade(nil, nil, agentAuth{})
	c.Check(err, gc.Equals, common.ErrPerm)
	c.Check(facade, gc.IsNil)
}
Exemple #3
0
func (*FacadeSuite) TestAcceptsMachineAgent(c *gc.C) {
	facade, err := machineactions.NewFacade(nil, nil, agentAuth{machine: true})
	c.Check(err, jc.ErrorIsNil)
	c.Check(facade, gc.NotNil)
}