Exemplo n.º 1
0
func (s *ModelCommandSuite) TestGetCurrentModelNothingSet(c *gc.C) {
	err := modelcmd.WriteCurrentController("")
	c.Assert(err, jc.ErrorIsNil)
	env, err := modelcmd.GetCurrentModel(s.store)
	c.Assert(env, gc.Equals, "")
	c.Assert(err, jc.ErrorIsNil)
}
Exemplo n.º 2
0
func (s *ModelCommandSuite) TestGetCurrentModelCurrentControllerAccountModel(c *gc.C) {
	err := s.store.UpdateModel("foo", "bar@baz", "mymodel", jujuclient.ModelDetails{"uuid"})
	c.Assert(err, jc.ErrorIsNil)
	err = s.store.SetCurrentModel("foo", "bar@baz", "mymodel")
	c.Assert(err, jc.ErrorIsNil)

	env, err := modelcmd.GetCurrentModel(s.store)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(env, gc.Equals, "mymodel")
}
Exemplo n.º 3
0
func (s *ModelCommandSuite) TestGetCurrentModelBothSet(c *gc.C) {
	os.Setenv(osenv.JujuModelEnvKey, "magic")

	err := s.store.UpdateModel("foo", "bar@baz", "mymodel", jujuclient.ModelDetails{"uuid"})
	c.Assert(err, jc.ErrorIsNil)
	err = s.store.SetCurrentModel("foo", "bar@baz", "mymodel")
	c.Assert(err, jc.ErrorIsNil)

	env, err := modelcmd.GetCurrentModel(s.store)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(env, gc.Equals, "magic")
}
Exemplo n.º 4
0
Arquivo: show.go Projeto: kat-co/juju
// Init implements Command.Init.
func (c *showModelCommand) Init(args []string) error {
	if len(args) > 0 {
		c.SetModelName(args[0])
		args = args[1:]
	}
	if err := c.ModelCommandBase.Init(args); err != nil {
		return err
	}
	if c.ModelName() == "" {
		defaultModel, err := modelcmd.GetCurrentModel(c.ClientStore())
		if err != nil {
			return err
		}
		c.SetModelName(defaultModel)
	}
	return nil
}
Exemplo n.º 5
0
func (s *ModelCommandSuite) TestGetCurrentModelJujuEnvSet(c *gc.C) {
	os.Setenv(osenv.JujuModelEnvKey, "magic")
	env, err := modelcmd.GetCurrentModel(s.store)
	c.Assert(env, gc.Equals, "magic")
	c.Assert(err, jc.ErrorIsNil)
}
Exemplo n.º 6
0
func (s *ModelCommandSuite) TestGetCurrentModelCurrentControllerNoCurrentModel(c *gc.C) {
	env, err := modelcmd.GetCurrentModel(s.store)
	c.Assert(env, gc.Equals, "")
	c.Assert(err, jc.ErrorIsNil)
}