• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang modelcmd.NewModelCommandBase函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/juju/juju/cmd/modelcmd.NewModelCommandBase函数的典型用法代码示例。如果您正苦于以下问题:Golang NewModelCommandBase函数的具体用法?Golang NewModelCommandBase怎么用?Golang NewModelCommandBase使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewModelCommandBase函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestsUnknownUserLogin

func (s *macaroonLoginSuite) TestsUnknownUserLogin(c *gc.C) {
	s.DischargerLogin = func() string {
		return "[email protected]"
	}

	cmd := modelcmd.NewModelCommandBase(s.store, s.controllerName, s.accountName, s.modelName)
	_, err := cmd.NewAPIRoot()
	c.Assert(err, gc.ErrorMatches, "connecting with cached addresses: invalid entity name or password \\(unauthorized access\\)")
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:9,代码来源:modelcommand_test.go


示例2: TestsSuccessfulLogin

func (s *macaroonLoginSuite) TestsSuccessfulLogin(c *gc.C) {
	s.DischargerLogin = func() string {
		return testUser
	}

	cmd := modelcmd.NewModelCommandBase(s.store, s.controllerName, s.accountName, s.modelName)
	_, err := cmd.NewAPIRoot()
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:9,代码来源:modelcommand_test.go


示例3: TestsFailToObtainDischargeLogin

func (s *macaroonLoginSuite) TestsFailToObtainDischargeLogin(c *gc.C) {
	s.DischargerLogin = func() string {
		return ""
	}

	cmd := modelcmd.NewModelCommandBase(s.store, s.controllerName, s.accountName, s.modelName)
	_, err := cmd.NewAPIRoot()
	c.Assert(err, gc.ErrorMatches, "connecting with cached addresses: cannot get discharge.*")
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:9,代码来源:modelcommand_test.go


示例4: TestsSuccessfulLogin

func (s *macaroonLoginSuite) TestsSuccessfulLogin(c *gc.C) {
	s.DischargerLogin = func() string {
		return testUser
	}

	cmd := modelcmd.NewModelCommandBase(s.envName, nil, nil)
	_, err := cmd.NewAPIRoot()
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:exekias,项目名称:juju,代码行数:9,代码来源:modelcommand_test.go


示例5: TestConfigEnvDoesntExist

func (s *EnvConfigSuite) TestConfigEnvDoesntExist(c *gc.C) {
	cmd := modelcmd.NewModelCommandBase("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)
}
开发者ID:exekias,项目名称:juju,代码行数:9,代码来源:modelcommand_test.go


示例6: TestConfigWithNoBootstrapWithClientErr

func (s *EnvConfigSuite) TestConfigWithNoBootstrapWithClientErr(c *gc.C) {
	cmd := modelcmd.NewModelCommandBase(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)
}
开发者ID:exekias,项目名称:juju,代码行数:9,代码来源:modelcommand_test.go


示例7: TestsUnknownUserLogin

func (s *macaroonLoginSuite) TestsUnknownUserLogin(c *gc.C) {
	s.DischargerLogin = func() string {
		return "[email protected]"
	}

	cmd := modelcmd.NewModelCommandBase(s.envName, nil, nil)
	_, err := cmd.NewAPIRoot()
	// TODO(rog) is this really the right error here?
	c.Assert(err, gc.ErrorMatches, `model "`+s.envName+`" not found`)
}
开发者ID:exekias,项目名称:juju,代码行数:10,代码来源:modelcommand_test.go


示例8: TestConfigWithNoBootstrapWithEnvGetError

func (s *EnvConfigSuite) TestConfigWithNoBootstrapWithEnvGetError(c *gc.C) {
	cmd := modelcmd.NewModelCommandBase(s.envName, s.client, nil)
	s.writeStore(c, false)
	s.client.err = errors.New("problem getting model attributes")

	_, err := cmd.Config(s.store, nil)
	c.Assert(err, gc.ErrorMatches, "problem getting model attributes")
	c.Check(s.client.getCalled, jc.IsTrue)
	c.Check(s.client.closeCalled, jc.IsTrue)
}
开发者ID:exekias,项目名称:juju,代码行数:10,代码来源:modelcommand_test.go


示例9: TestConfigWithNoBootstrapNoClient

func (s *EnvConfigSuite) TestConfigWithNoBootstrapNoClient(c *gc.C) {
	cmd := modelcmd.NewModelCommandBase(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)
}
开发者ID:exekias,项目名称:juju,代码行数:10,代码来源:modelcommand_test.go


示例10: assertUnknownModel

func (s *BaseCommandSuite) assertUnknownModel(c *gc.C, current, expectedCurrent string) {
	s.store.Models["foo"].CurrentModel = current
	apiOpen := func(*api.Info, api.DialOpts) (api.Connection, error) {
		return nil, errors.Trace(&params.Error{Code: params.CodeModelNotFound, Message: "model deaddeaf not found"})
	}
	cmd := modelcmd.NewModelCommandBase(s.store, "foo", "[email protected]/badmodel")
	cmd.SetAPIOpen(apiOpen)
	conn, err := cmd.NewAPIRoot()
	c.Assert(conn, gc.IsNil)
	msg := strings.Replace(err.Error(), "\n", "", -1)
	c.Assert(msg, gc.Equals, `model "[email protected]/badmodel" has been removed from the controller, run 'juju models' and switch to one of them.There are 1 accessible models on controller "foo".`)
	c.Assert(s.store.Models["foo"].Models, gc.HasLen, 1)
	c.Assert(s.store.Models["foo"].Models["[email protected]/goodmodel"], gc.DeepEquals, jujuclient.ModelDetails{"deadbeef2"})
	c.Assert(s.store.Models["foo"].CurrentModel, gc.Equals, expectedCurrent)
}
开发者ID:kat-co,项目名称:juju,代码行数:15,代码来源:base_test.go



注:本文中的github.com/juju/juju/cmd/modelcmd.NewModelCommandBase函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang modelcmd.Wrap函数代码示例发布时间:2022-05-23
下一篇:
Golang modelcmd.BootstrapContext函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap