当前位置: 首页>>代码示例>>Golang>>正文


Golang testing.InitCommand函数代码示例

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


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

示例1: TestInit

func (s *listCommandSuite) TestInit(c *gc.C) {
	cmd := block.NewListCommand()
	err := testing.InitCommand(cmd, nil)
	c.Check(err, jc.ErrorIsNil)

	err = testing.InitCommand(cmd, []string{"anything"})
	c.Check(err.Error(), gc.Equals, `unrecognized args: ["anything"]`)
}
开发者ID:bac,项目名称:juju,代码行数:8,代码来源:list_test.go

示例2: TestInit

func (s *UnsetSuite) TestInit(c *gc.C) {
	unsetCmd := environment.NewUnsetCommand(s.fake)
	// Only empty is a problem.
	err := testing.InitCommand(unsetCmd, []string{})
	c.Assert(err, gc.ErrorMatches, "no keys specified")
	// Everything else is fine.
	err = testing.InitCommand(unsetCmd, []string{"something", "weird"})
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:snailwalker,项目名称:juju,代码行数:9,代码来源:unset_test.go

示例3: TestInit

func (s *UnregisterSuite) TestInit(c *gc.C) {
	unregisterCommand := controller.NewUnregisterCommand(s.store)

	err := testing.InitCommand(unregisterCommand, []string{})
	c.Assert(err, gc.ErrorMatches, "controller name must be specified")

	err = testing.InitCommand(unregisterCommand, []string{"foo", "bar"})
	c.Assert(err, gc.ErrorMatches, `unrecognized args: \["bar"\]`)
}
开发者ID:bac,项目名称:juju,代码行数:9,代码来源:unregister_test.go

示例4: TestInit

func (s *GetSuite) TestInit(c *gc.C) {
	// zero or one args is fine.
	err := testing.InitCommand(&environment.GetCommand{}, nil)
	c.Check(err, jc.ErrorIsNil)
	err = testing.InitCommand(&environment.GetCommand{}, []string{"one"})
	c.Check(err, jc.ErrorIsNil)
	// More than one is not allowed.
	err = testing.InitCommand(&environment.GetCommand{}, []string{"one", "two"})
	c.Check(err, gc.ErrorMatches, `unrecognized args: \["two"\]`)
}
开发者ID:Pankov404,项目名称:juju,代码行数:10,代码来源:get_test.go

示例5: TestInit

func (s *GetConfigSuite) TestInit(c *gc.C) {
	// zero or one args is fine.
	err := testing.InitCommand(controller.NewGetConfigCommandForTest(&fakeControllerAPI{}, s.store), nil)
	c.Check(err, jc.ErrorIsNil)
	err = testing.InitCommand(controller.NewGetConfigCommandForTest(&fakeControllerAPI{}, s.store), []string{"one"})
	c.Check(err, jc.ErrorIsNil)
	// More than one is not allowed.
	err = testing.InitCommand(controller.NewGetConfigCommandForTest(&fakeControllerAPI{}, s.store), []string{"one", "two"})
	c.Check(err, gc.ErrorMatches, `unrecognized args: \["two"\]`)
}
开发者ID:bac,项目名称:juju,代码行数:10,代码来源:getconfig_test.go

示例6: TestInitRevokeAddModel

// TestInitRevokeAddModel checks that both the documented 'add-model' access and
// the backwards-compatible 'addmodel' work to revoke the AddModel permission.
func (s *grantSuite) TestInitRevokeAddModel(c *gc.C) {
	wrappedCmd, revokeCmd := model.NewRevokeCommandForTest(s.fake, s.store)
	// The documented case, add-model.
	err := testing.InitCommand(wrappedCmd, []string{"bob", "add-model"})
	c.Check(err, jc.ErrorIsNil)

	// The backwards-compatible case, addmodel.
	err = testing.InitCommand(wrappedCmd, []string{"bob", "addmodel"})
	c.Check(err, jc.ErrorIsNil)
	c.Assert(revokeCmd.Access, gc.Equals, "add-model")
}
开发者ID:bac,项目名称:juju,代码行数:13,代码来源:grantrevoke_test.go

示例7: TestInit

func (s *LoginSuite) TestInit(c *gc.C) {
	loginCommand := system.NewLoginCommand(nil, nil)

	err := testing.InitCommand(loginCommand, []string{})
	c.Assert(err, gc.ErrorMatches, "no name specified")

	err = testing.InitCommand(loginCommand, []string{"foo"})
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(loginCommand.Name, gc.Equals, "foo")

	err = testing.InitCommand(loginCommand, []string{"foo", "bar"})
	c.Assert(err, gc.ErrorMatches, `unrecognized args: \["bar"\]`)
}
开发者ID:andrewdmcleod,项目名称:juju,代码行数:13,代码来源:login_test.go

示例8: TestDestroyEnvironmentCommandConfirmationFlag

func (*destroyEnvSuite) TestDestroyEnvironmentCommandConfirmationFlag(c *gc.C) {
	com := new(DestroyEnvironmentCommand)
	c.Check(coretesting.InitCommand(com, []string{"dummyenv"}), gc.IsNil)
	c.Check(com.assumeYes, gc.Equals, false)

	com = new(DestroyEnvironmentCommand)
	c.Check(coretesting.InitCommand(com, []string{"dummyenv", "-y"}), gc.IsNil)
	c.Check(com.assumeYes, gc.Equals, true)

	com = new(DestroyEnvironmentCommand)
	c.Check(coretesting.InitCommand(com, []string{"dummyenv", "--yes"}), gc.IsNil)
	c.Check(com.assumeYes, gc.Equals, true)
}
开发者ID:jiasir,项目名称:juju,代码行数:13,代码来源:destroyenvironment_test.go

示例9: TestDestroyEnvironmentCommandConfirmationFlag

func (*destroyEnvSuite) TestDestroyEnvironmentCommandConfirmationFlag(c *gc.C) {
	wrappedCom, com := NewDestroyEnvironmentCommand()
	c.Check(coretesting.InitCommand(wrappedCom, []string{"dummyenv"}), gc.IsNil)
	c.Check(com.assumeYes, jc.IsFalse)

	wrappedCom, com = NewDestroyEnvironmentCommand()
	c.Check(coretesting.InitCommand(wrappedCom, []string{"dummyenv", "-y"}), gc.IsNil)
	c.Check(com.assumeYes, jc.IsTrue)

	wrappedCom, com = NewDestroyEnvironmentCommand()
	c.Check(coretesting.InitCommand(wrappedCom, []string{"dummyenv", "--yes"}), gc.IsNil)
	c.Check(com.assumeYes, jc.IsTrue)
}
开发者ID:snailwalker,项目名称:juju,代码行数:13,代码来源:destroyenvironment_test.go

示例10: TestInit

func (s *unshareSuite) TestInit(c *gc.C) {
	wrappedCommand, unshareCmd := model.NewUnshareCommandForTest(s.fake)
	err := testing.InitCommand(wrappedCommand, []string{})
	c.Assert(err, gc.ErrorMatches, "no users specified")

	err = testing.InitCommand(wrappedCommand, []string{"not valid/0"})
	c.Assert(err, gc.ErrorMatches, `invalid username: "not valid/0"`)

	err = testing.InitCommand(wrappedCommand, []string{"[email protected]", "sam"})
	c.Assert(err, jc.ErrorIsNil)

	c.Assert(unshareCmd.Users[0], gc.Equals, names.NewUserTag("[email protected]"))
	c.Assert(unshareCmd.Users[1], gc.Equals, names.NewUserTag("sam"))
}
开发者ID:exekias,项目名称:juju,代码行数:14,代码来源:unshare_test.go

示例11: TestInit

func (s *grantSuite) TestInit(c *gc.C) {
	wrappedCmd, grantCmd := model.NewGrantCommandForTest(s.fake, s.store)
	err := testing.InitCommand(wrappedCmd, []string{})
	c.Assert(err, gc.ErrorMatches, "no user specified")

	err = testing.InitCommand(wrappedCmd, []string{"bob", "read", "model1", "model2"})
	c.Assert(err, jc.ErrorIsNil)

	c.Assert(grantCmd.User, gc.Equals, "bob")
	c.Assert(grantCmd.ModelNames, jc.DeepEquals, []string{"model1", "model2"})

	err = testing.InitCommand(wrappedCmd, []string{})
	c.Assert(err, gc.ErrorMatches, `no user specified`)
}
开发者ID:bac,项目名称:juju,代码行数:14,代码来源:grantrevoke_test.go

示例12: TestInit

func (s *unshareSuite) TestInit(c *gc.C) {
	unshareCmd := &environment.UnshareCommand{}
	err := testing.InitCommand(unshareCmd, []string{})
	c.Assert(err, gc.ErrorMatches, "no users specified")

	err = testing.InitCommand(unshareCmd, []string{"not valid/0"})
	c.Assert(err, gc.ErrorMatches, `invalid username: "not valid/0"`)

	err = testing.InitCommand(unshareCmd, []string{"[email protected]", "sam"})
	c.Assert(err, jc.ErrorIsNil)

	c.Assert(unshareCmd.Users[0], gc.Equals, names.NewUserTag("[email protected]"))
	c.Assert(unshareCmd.Users[1], gc.Equals, names.NewUserTag("sam"))
}
开发者ID:Pankov404,项目名称:juju,代码行数:14,代码来源:unshare_test.go

示例13: CheckAgentCommand

// CheckAgentCommand is a utility function for verifying that common agent
// options are handled by a Command; it returns an instance of that
// command pre-parsed, with any mandatory flags added.
func CheckAgentCommand(c *gc.C, create acCreator, args []string) cmd.Command {
	com, conf := create()
	err := coretesting.InitCommand(com, args)
	c.Assert(conf.dataDir, gc.Equals, "/var/lib/juju")
	badArgs := append(args, "--data-dir", "")
	com, conf = create()
	err = coretesting.InitCommand(com, badArgs)
	c.Assert(err, gc.ErrorMatches, "--data-dir option must be set")

	args = append(args, "--data-dir", "jd")
	com, conf = create()
	c.Assert(coretesting.InitCommand(com, args), gc.IsNil)
	c.Assert(conf.dataDir, gc.Equals, "jd")
	return com
}
开发者ID:rogpeppe,项目名称:juju,代码行数:18,代码来源:agent_test.go

示例14: run

func (s *cmdControllerSuite) run(c *gc.C, args ...string) *cmd.Context {
	context := testing.Context(c)
	command := commands.NewJujuCommand(context)
	c.Assert(testing.InitCommand(command, args), jc.ErrorIsNil)
	c.Assert(command.Run(context), jc.ErrorIsNil)
	return context
}
开发者ID:imoapps,项目名称:juju,代码行数:7,代码来源:cmd_juju_controller_test.go

示例15: TestInit

func (s *LoginCommandSuite) TestInit(c *gc.C) {
	for i, test := range []struct {
		args        []string
		user        string
		errorString string
	}{
		{
		// no args is fine
		}, {
			args: []string{"foobar"},
			user: "foobar",
		}, {
			args:        []string{"--foobar"},
			errorString: "flag provided but not defined: --foobar",
		}, {
			args:        []string{"foobar", "extra"},
			errorString: `unrecognized args: \["extra"\]`,
		},
	} {
		c.Logf("test %d", i)
		wrappedCommand, command := user.NewLoginCommandForTest(nil, s.store)
		err := coretesting.InitCommand(wrappedCommand, test.args)
		if test.errorString == "" {
			c.Check(command.User, gc.Equals, test.user)
		} else {
			c.Check(err, gc.ErrorMatches, test.errorString)
		}
	}
}
开发者ID:kat-co,项目名称:juju,代码行数:29,代码来源:login_test.go


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