func (s *BootstrapConfigSuite) TestBootstrapConfigForControllerNoFile(c *gc.C) {
	err := os.Remove(jujuclient.JujuBootstrapConfigPath())
	c.Assert(err, jc.ErrorIsNil)
	details, err := s.store.BootstrapConfigForController("not-found")
	c.Assert(err, gc.ErrorMatches, "bootstrap config for controller not-found not found")
	c.Assert(details, gc.IsNil)
}
func (s *cmdControllerSuite) testControllerDestroy(c *gc.C, forceAPI bool) {
	st := s.Factory.MakeModel(c, &factory.ModelParams{
		Name:        "just-a-controller",
		ConfigAttrs: testing.Attrs{"controller": true},
		CloudRegion: "dummy-region",
	})
	defer st.Close()
	factory.NewFactory(st).MakeApplication(c, nil)

	stop := make(chan struct{})
	done := make(chan struct{})
	// In order for the destroy controller command to complete we need to run
	// the code that the cleaner and undertaker workers would be running in
	// the agent in order to progress the lifecycle of the hosted model,
	// and cleanup the documents.
	go func() {
		defer close(done)
		a := testing.LongAttempt.Start()
		for a.Next() {
			err := s.State.Cleanup()
			c.Check(err, jc.ErrorIsNil)
			err = st.Cleanup()
			c.Check(err, jc.ErrorIsNil)
			err = st.ProcessDyingModel()
			if errors.Cause(err) != state.ErrModelNotDying {
				c.Check(err, jc.ErrorIsNil)
				if err == nil {
					// success!
					return
				}
			}
			select {
			case <-stop:
				return
			default:
				// retry
			}
		}
	}()

	if forceAPI {
		// Remove bootstrap config from the client store,
		// forcing the command to use the API.
		err := os.Remove(jujuclient.JujuBootstrapConfigPath())
		c.Assert(err, jc.ErrorIsNil)
	}

	ops := make(chan dummy.Operation, 1)
	dummy.Listen(ops)

	s.run(c, "destroy-controller", "kontroll", "-y", "--destroy-all-models", "--debug")
	close(stop)
	<-done

	destroyOp := (<-ops).(dummy.OpDestroy)
	c.Assert(destroyOp.Env, gc.Equals, "controller")
	c.Assert(destroyOp.Cloud, gc.Equals, "dummy")
	c.Assert(destroyOp.CloudRegion, gc.Equals, "dummy-region")

	store := jujuclient.NewFileClientStore()
	_, err := store.ControllerByName("kontroll")
	c.Assert(err, jc.Satisfies, errors.IsNotFound)
}