Пример #1
0
func newLeadershipService(
	c *gc.C, claimer coreleadership.Claimer, authorizer common.Authorizer,
) leadership.LeadershipService {
	if authorizer == nil {
		authorizer = stubAuthorizer{tag: names.NewUnitTag(StubUnitNm)}
	}
	result, err := leadership.NewLeadershipService(claimer, authorizer)
	c.Assert(err, jc.ErrorIsNil)
	return result
}
Пример #2
0
func (s *leadershipSuite) TestCreateUnauthorized(c *gc.C) {
	authorizer := &stubAuthorizer{
		tag: names.NewMachineTag("123"),
	}

	ldrSvc, err := leadership.NewLeadershipService(nil, authorizer)
	c.Check(ldrSvc, gc.IsNil)
	c.Check(err, gc.ErrorMatches, "permission denied")
	c.Check(err, jc.Satisfies, errors.IsUnauthorized)
}