本文整理汇总了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)
}
示例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")
}
示例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)
}
示例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
}
示例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)
}
示例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")
}
示例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)
}
示例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")
}
示例9: initTestControllerCommand
func initTestControllerCommand(c *gc.C, args ...string) (*testControllerCommand, error) {
cmd := new(testControllerCommand)
wrapped := modelcmd.WrapController(cmd)
return cmd, cmdtesting.InitCommand(wrapped, args)
}
示例10: initTestCommand
func initTestCommand(c *gc.C, args ...string) (*testCommand, error) {
cmd := new(testCommand)
wrapped := envcmd.Wrap(cmd)
return cmd, cmdtesting.InitCommand(wrapped, args)
}
示例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")
}
示例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)
}
示例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")
}