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 }
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) }