Exemplo n.º 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)
}
Exemplo n.º 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)
}
Exemplo n.º 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)
}
Exemplo n.º 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)
}
Exemplo n.º 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)
}
Exemplo n.º 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`)
}