Пример #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)
}
Пример #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")
}
Пример #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")
}
Пример #4
0
// 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
}
Пример #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)
}
Пример #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)
}