func (s *InstancePollerSuite) TestNewInstancePollerAPIRequiresEnvironManager(c *gc.C) { anAuthoriser := s.authoriser anAuthoriser.EnvironManager = false api, err := instancepoller.NewInstancePollerAPI(nil, s.resources, anAuthoriser, s.clock) c.Assert(api, gc.IsNil) c.Assert(err, gc.ErrorMatches, "permission denied") }
func (s *InstancePollerSuite) SetUpTest(c *gc.C) { s.BaseSuite.SetUpTest(c) s.authoriser = apiservertesting.FakeAuthorizer{ EnvironManager: true, } s.resources = common.NewResources() s.AddCleanup(func(*gc.C) { s.resources.StopAll() }) s.st = NewMockState() instancepoller.PatchState(s, s.st) var err error s.clock = jujutesting.NewClock(time.Now()) s.api, err = instancepoller.NewInstancePollerAPI(nil, s.resources, s.authoriser, s.clock) c.Assert(err, jc.ErrorIsNil) s.machineEntities = params.Entities{ Entities: []params.Entity{ {Tag: "machine-1"}, {Tag: "machine-2"}, {Tag: "machine-3"}, }} s.machineErrorResults = params.ErrorResults{ Results: []params.ErrorResult{ {Error: apiservertesting.ServerError("pow!")}, {Error: apiservertesting.ServerError("FAIL")}, {Error: apiservertesting.NotProvisionedError("42")}, }} s.mixedEntities = params.Entities{ Entities: []params.Entity{ {Tag: "machine-1"}, {Tag: "machine-2"}, {Tag: "machine-42"}, {Tag: "application-unknown"}, {Tag: "invalid-tag"}, {Tag: "unit-missing-1"}, {Tag: ""}, {Tag: "42"}, }} s.mixedErrorResults = params.ErrorResults{ Results: []params.ErrorResult{ {Error: nil}, {Error: nil}, {Error: apiservertesting.NotFoundError("machine 42")}, {Error: apiservertesting.ServerError(`"application-unknown" is not a valid machine tag`)}, {Error: apiservertesting.ServerError(`"invalid-tag" is not a valid tag`)}, {Error: apiservertesting.ServerError(`"unit-missing-1" is not a valid machine tag`)}, {Error: apiservertesting.ServerError(`"" is not a valid tag`)}, {Error: apiservertesting.ServerError(`"42" is not a valid tag`)}, }} }