Пример #1
0
func (s *EnvConfigSuite) TestConfigEnvDoesntExist(c *gc.C) {
	cmd := envcmd.NewEnvCommandBase("dummy", s.client, nil)
	s.writeStore(c, false)

	_, err := cmd.Config(s.store, nil)
	c.Assert(err, jc.Satisfies, errors.IsNotFound)
	c.Check(s.client.getCalled, jc.IsFalse)
	c.Check(s.client.closeCalled, jc.IsFalse)
}
Пример #2
0
func (s *EnvConfigSuite) TestConfigWithNoBootstrapWithClientErr(c *gc.C) {
	cmd := envcmd.NewEnvCommandBase(s.envName, s.client, errors.New("problem opening connection"))
	s.writeStore(c, false)

	_, err := cmd.Config(s.store, nil)
	c.Assert(err, gc.ErrorMatches, "problem opening connection")
	c.Check(s.client.getCalled, jc.IsFalse)
	c.Check(s.client.closeCalled, jc.IsFalse)
}
Пример #3
0
func (s *macaroonLoginSuite) TestsSuccessfulLogin(c *gc.C) {
	s.DischargerLogin = func() string {
		return testUser
	}

	cmd := envcmd.NewEnvCommandBase(s.envName, nil, nil)
	_, err := cmd.NewAPIRoot()
	c.Assert(err, jc.ErrorIsNil)
}
Пример #4
0
func (s *EnvConfigSuite) TestConfigWithNoBootstrapWithEnvGetError(c *gc.C) {
	cmd := envcmd.NewEnvCommandBase(s.envName, s.client, nil)
	s.writeStore(c, false)
	s.client.err = errors.New("problem getting environment attributes")

	_, err := cmd.Config(s.store, nil)
	c.Assert(err, gc.ErrorMatches, "problem getting environment attributes")
	c.Check(s.client.getCalled, jc.IsTrue)
	c.Check(s.client.closeCalled, jc.IsTrue)
}
Пример #5
0
func (s *EnvConfigSuite) TestConfigWithNoBootstrapNoClient(c *gc.C) {
	cmd := envcmd.NewEnvCommandBase(s.envName, s.client, nil)
	s.writeStore(c, false)

	cfg, err := cmd.Config(s.store, nil)
	c.Assert(err, jc.ErrorIsNil)
	c.Check(cfg.Name(), gc.Equals, s.envName)
	c.Check(s.client.getCalled, jc.IsTrue)
	c.Check(s.client.closeCalled, jc.IsTrue)
}
Пример #6
0
func (s *macaroonLoginSuite) TestsUnknownUserLogin(c *gc.C) {
	s.DischargerLogin = func() string {
		return "testUnknown@nowhere"
	}

	cmd := envcmd.NewEnvCommandBase(s.envName, nil, nil)
	_, err := cmd.NewAPIRoot()
	// TODO(rog) is this really the right error here?
	c.Assert(err, gc.ErrorMatches, `environment "`+s.envName+`" not found`)
}