func (s *KillSuite) newKillCommandBoth() (cmd.Command, cmd.Command) { clock := s.clock if clock == nil { clock = testing.NewClock(time.Now()) } return controller.NewKillCommandForTest( s.api, s.clientapi, s.store, s.apierror, clock, nil) }
func (s *KillSuite) TestKillAPIPermErrFails(c *gc.C) { testDialer := func(_ jujuclient.ClientStore, controllerName, accountName, modelName string) (api.Connection, error) { return nil, common.ErrPerm } cmd := controller.NewKillCommandForTest(nil, nil, s.store, nil, clock.WallClock, modelcmd.OpenFunc(testDialer)) _, err := testing.RunCommand(c, cmd, "local.test1", "-y") c.Assert(err, gc.ErrorMatches, "cannot destroy controller: permission denied") checkControllerExistsInStore(c, "local.test1", s.store) }
func (s *KillSuite) TestKillAPIPermErrFails(c *gc.C) { testDialer := func(sysName string) (api.Connection, error) { return nil, common.ErrPerm } cmd := controller.NewKillCommandForTest(nil, nil, nil, clock.WallClock, testDialer) _, err := testing.RunCommand(c, cmd, "test1", "-y") c.Assert(err, gc.ErrorMatches, "cannot destroy controller: permission denied") checkControllerExistsInStore(c, "test1", s.store) }
func (s *KillSuite) TestKillEarlyAPIConnectionTimeout(c *gc.C) { clock := &mockClock{} stop := make(chan struct{}) defer close(stop) testDialer := func(_ jujuclient.ClientStore, controllerName, accountName, modelName string) (api.Connection, error) { <-stop return nil, errors.New("kill command waited too long") } cmd := controller.NewKillCommandForTest(nil, nil, s.store, nil, clock, modelcmd.OpenFunc(testDialer)) ctx, err := testing.RunCommand(c, cmd, "local.test1", "-y") c.Check(err, jc.ErrorIsNil) c.Check(testing.Stderr(ctx), jc.Contains, "Unable to open API: open connection timed out") checkControllerRemovedFromStore(c, "local.test1", s.store) // Check that we were actually told to wait for 10s. c.Assert(clock.wait, gc.Equals, 10*time.Second) }
func (s *KillSuite) newKillCommand() cmd.Command { return controller.NewKillCommandForTest( s.api, s.clientapi, s.store, s.apierror, &mockClock{}, nil) }
func (s *KillSuite) newKillCommand() cmd.Command { wrapped, _ := controller.NewKillCommandForTest( s.api, s.clientapi, s.store, s.apierror, s.clock, nil) return wrapped }