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

Golang cmdtesting.InitCommand函数代码示例

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

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



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

示例1: TestEnvironCommandInitErrors

func (s *EnvironmentCommandSuite) TestEnvironCommandInitErrors(c *gc.C) {
	envPath := gitjujutesting.HomePath(".juju", "environments.yaml")
	err := os.Remove(envPath)
	c.Assert(err, gc.IsNil)
	cmd := envcmd.Wrap(new(testCommand))
	err = cmdtesting.InitCommand(cmd, nil)
	c.Assert(err, jc.Satisfies, environs.IsNoEnv)

	// If there are multiple environments but no default,
	// an error should be returned.
	coretesting.WriteEnvironments(c, coretesting.MultipleEnvConfigNoDefault)
	err = cmdtesting.InitCommand(cmd, nil)
	c.Assert(err, gc.Equals, envcmd.ErrNoEnvironmentSpecified)
}
开发者ID:klyachin,项目名称:juju,代码行数:14,代码来源:environmentcommand_test.go


示例2: TestInit

func (s *deleteCharmSuite) TestInit(c *gc.C) {
	config := &DeleteCharmCommand{}
	err := cmdtesting.InitCommand(config, []string{"--config", "/etc/charmd.conf", "--url", "cs:go"})
	c.Assert(err, gc.IsNil)
	c.Assert(config.ConfigPath, gc.Equals, "/etc/charmd.conf")
	c.Assert(config.Url, gc.Equals, "cs:go")
}
开发者ID:rogpeppe,项目名称:charmstore,代码行数:7,代码来源:deletecharm_test.go


示例3: TestWrapWithoutFlags

func (s *ModelCommandSuite) TestWrapWithoutFlags(c *gc.C) {
	cmd := new(testCommand)
	wrapped := modelcmd.Wrap(cmd, modelcmd.ModelSkipFlags)
	args := []string{"-m", "testenv"}
	err := cmdtesting.InitCommand(wrapped, args)
	// 1st position is always the flag
	msg := fmt.Sprintf("flag provided but not defined: %v", args[0])
	c.Assert(err, gc.ErrorMatches, msg)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:9,代码来源:modelcommand_test.go


示例4: initTestControllerCommand

func initTestControllerCommand(c *gc.C, store jujuclient.ClientStore, args ...string) (cmd.Command, *testControllerCommand, error) {
	cmd := new(testControllerCommand)
	cmd.SetClientStore(store)
	wrapped := modelcmd.WrapController(cmd)
	if err := cmdtesting.InitCommand(wrapped, args); err != nil {
		return nil, nil, err
	}
	return wrapped, cmd, nil
}
开发者ID:kat-co,项目名称:juju,代码行数:9,代码来源:controller_test.go


示例5: initDefenestrateWithAliases

func initDefenestrateWithAliases(c *gc.C, args []string) (*cmd.SuperCommand, *TestCommand, error) {
	dir := c.MkDir()
	filename := filepath.Join(dir, "aliases")
	err := ioutil.WriteFile(filename, []byte(`
def = defenestrate
be-firm = defenestrate --option firmly
other = missing 
		`), 0644)
	c.Assert(err, gc.IsNil)
	jc := cmd.NewSuperCommand(cmd.SuperCommandParams{Name: "jujutest", UserAliasesFilename: filename})
	tc := &TestCommand{Name: "defenestrate"}
	jc.Register(tc)
	return jc, tc, cmdtesting.InitCommand(jc, args)
}
开发者ID:juju,项目名称:cmd,代码行数:14,代码来源:supercommand_test.go


示例6: TestReadConfig

func (s *configSuite) TestReadConfig(c *gc.C) {
	configPath := filepath.Join(c.MkDir(), "charmd.conf")
	err := ioutil.WriteFile(configPath, []byte(testConfig), 0666)
	c.Assert(err, gc.IsNil)

	config := &someConfigCommand{}
	args := []string{"--config", configPath}
	err = cmdtesting.InitCommand(config, args)
	c.Assert(err, gc.IsNil)
	_, err = cmdtesting.RunCommand(c, config, args...)
	c.Assert(err, gc.IsNil)

	c.Assert(config.Config, gc.NotNil)
	c.Assert(config.Config.MongoURL, gc.Equals, "localhost:23456")
}
开发者ID:howbazaar,项目名称:charmstore,代码行数:15,代码来源:config_test.go


示例7: initTestCommand

func initTestCommand(c *gc.C, store jujuclient.ClientStore, args ...string) (*testCommand, error) {
	cmd := new(testCommand)
	cmd.SetClientStore(store)
	wrapped := modelcmd.Wrap(cmd)
	return cmd, cmdtesting.InitCommand(wrapped, args)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:6,代码来源:modelcommand_test.go


示例8: TestWrapWithoutFlags

func (s *ControllerCommandSuite) TestWrapWithoutFlags(c *gc.C) {
	cmd := new(testControllerCommand)
	wrapped := modelcmd.WrapController(cmd, modelcmd.ControllerSkipFlags)
	err := cmdtesting.InitCommand(wrapped, []string{"-s", "testsys"})
	c.Assert(err, gc.ErrorMatches, "flag provided but not defined: -s")
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:6,代码来源:controller_test.go


示例9: initTestControllerCommand

func initTestControllerCommand(c *gc.C, args ...string) (*testControllerCommand, error) {
	cmd := new(testControllerCommand)
	wrapped := modelcmd.WrapController(cmd)
	return cmd, cmdtesting.InitCommand(wrapped, args)
}
开发者ID:exekias,项目名称:juju,代码行数:5,代码来源:controller_test.go


示例10: initTestCommand

func initTestCommand(c *gc.C, args ...string) (*testCommand, error) {
	cmd := new(testCommand)
	wrapped := envcmd.Wrap(cmd)
	return cmd, cmdtesting.InitCommand(wrapped, args)
}
开发者ID:klyachin,项目名称:juju,代码行数:5,代码来源:environmentcommand_test.go


示例11: TestWrapWithoutFlags

func (s *EnvironmentCommandSuite) TestWrapWithoutFlags(c *gc.C) {
	cmd := new(testCommand)
	wrapped := envcmd.Wrap(cmd, envcmd.EnvSkipFlags)
	err := cmdtesting.InitCommand(wrapped, []string{"-e", "testenv"})
	c.Assert(err, gc.ErrorMatches, "flag provided but not defined: -e")
}
开发者ID:imoapps,项目名称:juju,代码行数:6,代码来源:environmentcommand_test.go


示例12: initDefenestrate

func initDefenestrate(args []string) (*cmd.SuperCommand, *TestCommand, error) {
	jc := cmd.NewSuperCommand(cmd.SuperCommandParams{Name: "jujutest"})
	tc := &TestCommand{Name: "defenestrate"}
	jc.Register(tc)
	return jc, tc, cmdtesting.InitCommand(jc, args)
}
开发者ID:bogdanteleaga,项目名称:cmd,代码行数:6,代码来源:supercommand_test.go


示例13: TestWrapWithoutFlags

func (s *SystemCommandSuite) TestWrapWithoutFlags(c *gc.C) {
	cmd := new(testSystemCommand)
	wrapped := envcmd.WrapSystem(cmd, envcmd.SystemSkipFlags)
	err := cmdtesting.InitCommand(wrapped, []string{"-s", "testsys"})
	c.Assert(err, gc.ErrorMatches, "flag provided but not defined: -s")
}
开发者ID:snailwalker,项目名称:juju,代码行数:6,代码来源:systemcommand_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang cmdtesting.RunCommand函数代码示例发布时间:2022-05-23
下一篇:
Golang cmdtesting.Context函数代码示例发布时间: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