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

Golang application.NewConfigCommandForTest函数代码示例

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

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



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

示例1: assertSetWarning

func (s *configCommandSuite) assertSetWarning(c *gc.C, dir string, args []string, w string) {
	ctx := coretesting.ContextForDir(c, dir)
	code := cmd.Main(application.NewConfigCommandForTest(s.fake), ctx, append([]string{"dummy-application"}, args...))
	c.Check(code, gc.Equals, 0)

	c.Assert(strings.Replace(c.GetTestLog(), "\n", " ", -1), gc.Matches, ".*WARNING.*"+w+".*")
}
开发者ID:bac,项目名称:juju,代码行数:7,代码来源:config_test.go


示例2: TestGetConfigKeyNotFound

func (s *configCommandSuite) TestGetConfigKeyNotFound(c *gc.C) {
	ctx := coretesting.Context(c)
	code := cmd.Main(application.NewConfigCommandForTest(s.fake), ctx, []string{"dummy-application", "invalid"})
	c.Check(code, gc.Equals, 1)
	c.Assert(ctx.Stderr.(*bytes.Buffer).String(), gc.Equals, "error: key \"invalid\" not found in \"dummy-application\" application settings.\n")
	c.Assert(ctx.Stdout.(*bytes.Buffer).String(), gc.Equals, "")
}
开发者ID:bac,项目名称:juju,代码行数:7,代码来源:config_test.go


示例3: TestGetConfigKey

func (s *configCommandSuite) TestGetConfigKey(c *gc.C) {
	ctx := coretesting.Context(c)
	code := cmd.Main(application.NewConfigCommandForTest(s.fake), ctx, []string{"dummy-application", "title"})
	c.Check(code, gc.Equals, 0)
	c.Assert(ctx.Stderr.(*bytes.Buffer).String(), gc.Equals, "")
	c.Assert(ctx.Stdout.(*bytes.Buffer).String(), gc.Equals, "Nearly There\n")
}
开发者ID:bac,项目名称:juju,代码行数:7,代码来源:config_test.go


示例4: TestSetFromStdin

func (s *configCommandSuite) TestSetFromStdin(c *gc.C) {
	s.fake = &fakeApplicationAPI{name: "dummy-application"}
	ctx := coretesting.Context(c)
	ctx.Stdin = strings.NewReader("settings:\n  username:\n  value: world\n")
	code := cmd.Main(application.NewConfigCommandForTest(s.fake), ctx, []string{
		"dummy-application",
		"--file",
		"-"})

	c.Check(code, gc.Equals, 0)
	c.Check(s.fake.config, jc.DeepEquals, "settings:\n  username:\n  value: world\n")
}
开发者ID:bac,项目名称:juju,代码行数:12,代码来源:config_test.go


示例5: TestBlockSetConfig

func (s *configCommandSuite) TestBlockSetConfig(c *gc.C) {
	// Block operation
	s.fake.err = common.OperationBlockedError("TestBlockSetConfig")
	ctx := coretesting.ContextForDir(c, s.dir)
	code := cmd.Main(application.NewConfigCommandForTest(s.fake), ctx, []string{
		"dummy-application",
		"--file",
		"testconfig.yaml"})
	c.Check(code, gc.Equals, 1)
	// msg is logged
	stripped := strings.Replace(c.GetTestLog(), "\n", "", -1)
	c.Check(stripped, gc.Matches, ".*TestBlockSetConfig.*")
}
开发者ID:bac,项目名称:juju,代码行数:13,代码来源:config_test.go


示例6: TestSetCommandInit

func (s *configCommandSuite) TestSetCommandInit(c *gc.C) {
	// missing args
	err := coretesting.InitCommand(application.NewConfigCommandForTest(s.fake), []string{})
	c.Assert(err, gc.ErrorMatches, "no application name specified")

	// missing application name
	err = coretesting.InitCommand(application.NewConfigCommandForTest(s.fake), []string{"name=foo"})
	c.Assert(err, gc.ErrorMatches, "no application name specified")

	// --file path, but no application
	err = coretesting.InitCommand(application.NewConfigCommandForTest(s.fake), []string{"--file", "testconfig.yaml"})
	c.Assert(err, gc.ErrorMatches, "no application name specified")

	// --file and options specified
	err = coretesting.InitCommand(application.NewConfigCommandForTest(s.fake), []string{"application", "--file", "testconfig.yaml", "bees="})
	c.Assert(err, gc.ErrorMatches, "cannot specify --file and key=value arguments simultaneously")

	// --reset and no config name provided
	err = coretesting.InitCommand(application.NewConfigCommandForTest(s.fake), []string{"application", "--reset"})
	c.Assert(err, gc.ErrorMatches, "no configuration options specified")

}
开发者ID:kat-co,项目名称:juju,代码行数:22,代码来源:config_test.go


示例7: TestSetConfig

func (s *configCommandSuite) TestSetConfig(c *gc.C) {
	s.assertSetFail(c, s.dir, []string{
		"--file",
		"missing.yaml",
	}, "error.* "+utils.NoSuchFileErrRegexp+"\n")

	ctx := coretesting.ContextForDir(c, s.dir)
	code := cmd.Main(application.NewConfigCommandForTest(s.fake), ctx, []string{
		"dummy-application",
		"--file",
		"testconfig.yaml"})

	c.Check(code, gc.Equals, 0)
	c.Check(s.fake.config, gc.Equals, yamlConfigValue)
}
开发者ID:bac,项目名称:juju,代码行数:15,代码来源:config_test.go


示例8: TestSetCommandInit

func (s *configCommandSuite) TestSetCommandInit(c *gc.C) {
	// missing args
	err := coretesting.InitCommand(application.NewConfigCommandForTest(s.fake), []string{})
	c.Assert(err, gc.ErrorMatches, "no application name specified")

	// missing application name
	err = coretesting.InitCommand(application.NewConfigCommandForTest(s.fake), []string{"name=foo"})
	c.Assert(err, gc.ErrorMatches, "no application name specified")

	// --file path, but no application
	err = coretesting.InitCommand(application.NewConfigCommandForTest(s.fake), []string{"--file", "testconfig.yaml"})
	c.Assert(err, gc.ErrorMatches, "no application name specified")

	// --file and options specified
	err = coretesting.InitCommand(application.NewConfigCommandForTest(s.fake), []string{"application", "--file", "testconfig.yaml", "bees="})
	c.Assert(err, gc.ErrorMatches, "cannot specify --file and key=value arguments simultaneously")

	// --reset and no config name provided
	err = coretesting.InitCommand(application.NewConfigCommandForTest(s.fake), []string{"application", "--reset"})
	c.Assert(err, gc.ErrorMatches, "flag needs an argument: --reset")

	// cannot set and retrieve simultaneously
	err = coretesting.InitCommand(application.NewConfigCommandForTest(s.fake), []string{"application", "get", "set=value"})
	c.Assert(err, gc.ErrorMatches, "cannot set and retrieve values simultaneously")

	// cannot reset and get simultaneously
	err = coretesting.InitCommand(application.NewConfigCommandForTest(s.fake), []string{"application", "--reset", "reset", "get"})
	c.Assert(err, gc.ErrorMatches, "cannot reset and retrieve values simultaneously")

	// invalid reset keys
	err = coretesting.InitCommand(application.NewConfigCommandForTest(s.fake), []string{"application", "--reset", "reset,bad=key"})
	c.Assert(err, gc.ErrorMatches, `--reset accepts a comma delimited set of keys "a,b,c", received: "bad=key"`)

	// init too many args fails
	err = coretesting.InitCommand(application.NewConfigCommandForTest(s.fake), []string{"application", "key", "another"})
	c.Assert(err, gc.ErrorMatches, "can only retrieve a single value, or all values")

}
开发者ID:bac,项目名称:juju,代码行数:38,代码来源:config_test.go


示例9: TestGetConfig

func (s *configCommandSuite) TestGetConfig(c *gc.C) {
	for _, t := range getTests {
		ctx := coretesting.Context(c)
		code := cmd.Main(application.NewConfigCommandForTest(s.fake), ctx, []string{t.application})
		c.Check(code, gc.Equals, 0)
		c.Assert(ctx.Stderr.(*bytes.Buffer).String(), gc.Equals, "")
		// round trip via goyaml to avoid being sucked into a quagmire of
		// map[interface{}]interface{} vs map[string]interface{}. This is
		// also required if we add json support to this command.
		buf, err := goyaml.Marshal(t.expected)
		c.Assert(err, jc.ErrorIsNil)
		expected := make(map[string]interface{})
		err = goyaml.Unmarshal(buf, &expected)
		c.Assert(err, jc.ErrorIsNil)

		actual := make(map[string]interface{})
		err = goyaml.Unmarshal(ctx.Stdout.(*bytes.Buffer).Bytes(), &actual)
		c.Assert(err, jc.ErrorIsNil)
		c.Assert(actual, gc.DeepEquals, expected)
	}
}
开发者ID:bac,项目名称:juju,代码行数:21,代码来源:config_test.go


示例10: TestGetCommandInitWithApplication

func (s *configCommandSuite) TestGetCommandInitWithApplication(c *gc.C) {
	err := coretesting.InitCommand(application.NewConfigCommandForTest(s.fake), []string{"app"})
	// everything ok
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:bac,项目名称:juju,代码行数:5,代码来源:config_test.go


示例11: TestGetCommandInit

func (s *configCommandSuite) TestGetCommandInit(c *gc.C) {
	// missing args
	err := coretesting.InitCommand(application.NewConfigCommandForTest(s.fake), []string{})
	c.Assert(err, gc.ErrorMatches, "no application name specified")
}
开发者ID:bac,项目名称:juju,代码行数:5,代码来源:config_test.go


示例12: assertSetFail

// assertSetFail sets configuration options and checks the expected error.
func (s *configCommandSuite) assertSetFail(c *gc.C, dir string, args []string, err string) {
	ctx := coretesting.ContextForDir(c, dir)
	code := cmd.Main(application.NewConfigCommandForTest(s.fake), ctx, append([]string{"dummy-application"}, args...))
	c.Check(code, gc.Not(gc.Equals), 0)
	c.Assert(ctx.Stderr.(*bytes.Buffer).String(), gc.Matches, err)
}
开发者ID:bac,项目名称:juju,代码行数:7,代码来源:config_test.go


示例13: assertSetSuccess

// assertSetSuccess sets configuration options and checks the expected settings.
func (s *configCommandSuite) assertSetSuccess(c *gc.C, dir string, args []string, expect map[string]interface{}) {
	ctx := coretesting.ContextForDir(c, dir)
	code := cmd.Main(application.NewConfigCommandForTest(s.fake), ctx, append([]string{"dummy-application"}, args...))
	c.Assert(code, gc.Equals, 0)
}
开发者ID:bac,项目名称:juju,代码行数:6,代码来源:config_test.go


示例14: TestGetCommandInitTooManyArgs

func (s *configCommandSuite) TestGetCommandInitTooManyArgs(c *gc.C) {
	err := coretesting.InitCommand(application.NewConfigCommandForTest(s.fake), []string{"app", "key", "another"})
	c.Assert(err, gc.ErrorMatches, "can only retrieve a single value, or all values")
}
开发者ID:kat-co,项目名称:juju,代码行数:4,代码来源:config_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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