func (s *AddRelationSuite) TestAddRelationBlocked(c *gc.C) { s.mockAPI.SetErrors(common.OperationBlockedError("TestBlockAddRelation")) err := s.runAddRelation(c, "application1", "application2") coretesting.AssertOperationWasBlocked(c, err, ".*TestBlockAddRelation.*") s.mockAPI.CheckCall(c, 0, "AddRelation", []string{"application1", "application2"}) s.mockAPI.CheckCall(c, 1, "Close") }
func (s *RunSuite) TestBlockAllMachines(c *gc.C) { mock := s.setupMockAPI() // Block operation mock.block = true _, err := testing.RunCommand(c, newRunCommand(), "--format=json", "--all", "hostname") testing.AssertOperationWasBlocked(c, err, ".*To enable changes.*") }
func (s *syncToolsSuite) TestAPIAdapterBlockUploadTools(c *gc.C) { syncTools = func(sctx *sync.SyncContext) error { // Block operation return common.OperationBlockedError("TestAPIAdapterBlockUploadTools") } _, err := s.runSyncToolsCommand(c, "-m", "test-target", "--destination", c.MkDir(), "--stream", "released") coretesting.AssertOperationWasBlocked(c, err, ".*TestAPIAdapterBlockUploadTools.*") }
func (s *UpgradeJujuSuite) TestBlockUpgradeJujuWithRealUpload(c *gc.C) { s.Reset(c) s.PatchValue(&jujuversion.Current, version.MustParse("1.99.99")) cmd := newUpgradeJujuCommand(map[int]version.Number{2: version.MustParse("1.99.99")}) // Block operation s.BlockAllChanges(c, "TestBlockUpgradeJujuWithRealUpload") _, err := coretesting.RunCommand(c, cmd, "--build-agent") coretesting.AssertOperationWasBlocked(c, err, ".*TestBlockUpgradeJujuWithRealUpload.*") }
func (s *RunSuite) TestBlockRunForMachineAndUnit(c *gc.C) { mock := s.setupMockAPI() // Block operation mock.block = true _, err := testing.RunCommand(c, newRunCommand(), "--format=json", "--machine=0", "--unit=unit/0", "hostname", ) testing.AssertOperationWasBlocked(c, err, ".*To enable changes.*") }
func (s *ImportKeySuite) TestBlockImportKeys(c *gc.C) { key1 := sshtesting.ValidKeyOne.Key + " user@host" s.setAuthorizedKeys(c, key1) // Block operation s.BlockAllChanges(c, "TestBlockImportKeys") _, err := coretesting.RunCommand(c, NewImportKeysCommand(), "lp:validuser", "lp:invalid-key") coretesting.AssertOperationWasBlocked(c, err, ".*TestBlockImportKeys.*") }
func (s *AddKeySuite) TestBlockAddKey(c *gc.C) { key1 := sshtesting.ValidKeyOne.Key + " user@host" s.setAuthorizedKeys(c, key1) key2 := sshtesting.ValidKeyTwo.Key + " another@host" // Block operation s.BlockAllChanges(c, "TestBlockAddKey") _, err := coretesting.RunCommand(c, NewAddKeysCommand(), key2, "invalid-key") coretesting.AssertOperationWasBlocked(c, err, ".*TestBlockAddKey.*") }
func (s *RemoveKeySuite) TestBlockRemoveKeys(c *gc.C) { key1 := sshtesting.ValidKeyOne.Key + " user@host" key2 := sshtesting.ValidKeyTwo.Key + " another@host" s.setAuthorizedKeys(c, key1, key2) // Block operation s.BlockAllChanges(c, "TestBlockRemoveKeys") _, err := coretesting.RunCommand(c, NewRemoveKeysCommand(), sshtesting.ValidKeyTwo.Fingerprint, "invalid-key") coretesting.AssertOperationWasBlocked(c, err, ".*TestBlockRemoveKeys.*") }
func (s *retryProvisioningSuite) TestBlockRetryProvisioning(c *gc.C) { s.fake.err = common.OperationBlockedError("TestBlockRetryProvisioning") command := model.NewRetryProvisioningCommandForTest(s.fake) for i, t := range resolvedMachineTests { c.Logf("test %d: %v", i, t.args) _, err := testing.RunCommand(c, command, t.args...) if t.err != "" { c.Check(err, gc.ErrorMatches, t.err) continue } testing.AssertOperationWasBlocked(c, err, ".*TestBlockRetryProvisioning.*") } }
func (s *ResolvedSuite) TestBlockResolved(c *gc.C) { ch := testcharms.Repo.CharmArchivePath(s.CharmsPath, "dummy") err := runDeploy(c, "-n", "5", ch, "dummy", "--series", "quantal") c.Assert(err, jc.ErrorIsNil) // lp:1558657 now := time.Now() for _, name := range []string{"dummy/2", "dummy/3", "dummy/4"} { u, err := s.State.Unit(name) c.Assert(err, jc.ErrorIsNil) sInfo := status.StatusInfo{ Status: status.Error, Message: "lol borken", Since: &now, } err = u.SetAgentStatus(sInfo) c.Assert(err, jc.ErrorIsNil) } // Block operation s.BlockAllChanges(c, "TestBlockResolved") err = runResolved(c, []string{"dummy/2"}) testing.AssertOperationWasBlocked(c, err, ".*TestBlockResolved.*") }
func (s *AddMachineSuite) TestBlockedError(c *gc.C) { s.fakeAddMachine.addError = common.OperationBlockedError("TestBlockedError") _, err := s.run(c) testing.AssertOperationWasBlocked(c, err, ".*TestBlockedError.*") }
func (s *DefaultsCommandSuite) TestBlockedErrorOnSet(c *gc.C) { s.fakeDefaultsAPI.err = common.OperationBlockedError("TestBlockedError") _, err := s.run(c, "special=extra") testing.AssertOperationWasBlocked(c, err, ".*TestBlockedError.*") }
func (s *DefaultsCommandSuite) TestResetBlockedError(c *gc.C) { s.fakeDefaultsAPI.err = common.OperationBlockedError("TestBlockedError") _, err := s.run(c, "--reset", "attr") testing.AssertOperationWasBlocked(c, err, ".*TestBlockedError.*") }
func (s *grantRevokeSuite) TestBlockGrant(c *gc.C) { s.fake.err = common.OperationBlockedError("TestBlockGrant") _, err := s.run(c, "sam", "read", "foo") testing.AssertOperationWasBlocked(c, err, ".*TestBlockGrant.*") }
func (s *UserAddCommandSuite) TestBlockAddUser(c *gc.C) { // Block operation s.mockAPI.blocked = true _, err := s.run(c, "foobar", "Foo Bar") testing.AssertOperationWasBlocked(c, err, ".*To enable changes.*") }
func (s *EnableHASuite) TestBlockEnableHA(c *gc.C) { s.fake.err = common.OperationBlockedError("TestBlockEnableHA") _, err := s.runEnableHA(c, "-n", "1") coretesting.AssertOperationWasBlocked(c, err, ".*TestBlockEnableHA.*") }
func (s *ConfigCommandSuite) TestResetBlockedError(c *gc.C) { s.fake.err = common.OperationBlockedError("TestBlockedError") _, err := s.run(c, "--reset", "special") testing.AssertOperationWasBlocked(c, err, ".*TestBlockedError.*") }
func (s *DestroySuite) TestBlockedDestroy(c *gc.C) { s.api.err = common.OperationBlockedError("TestBlockedDestroy") _, err := s.runDestroyCommand(c, "test2", "-y") testing.AssertOperationWasBlocked(c, err, ".*TestBlockedDestroy.*") }