本文整理汇总了Golang中github.com/juju/juju/cmd/testing.RunCommand函数的典型用法代码示例。如果您正苦于以下问题:Golang RunCommand函数的具体用法?Golang RunCommand怎么用?Golang RunCommand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RunCommand函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestDestroyEnvironmentCommandEFlag
func (s *destroyEnvSuite) TestDestroyEnvironmentCommandEFlag(c *gc.C) {
// Prepare the environment so we can destroy it.
_, err := environs.PrepareFromName("dummyenv", cmdtesting.NullContext(c), s.ConfigStore)
c.Assert(err, gc.IsNil)
// check that either environment or the flag is mandatory
opc, errc := cmdtesting.RunCommand(cmdtesting.NullContext(c), new(DestroyEnvironmentCommand))
c.Check(<-errc, gc.Equals, NoEnvironmentError)
// We don't allow them to supply both entries at the same time
opc, errc = cmdtesting.RunCommand(cmdtesting.NullContext(c), new(DestroyEnvironmentCommand), "-e", "dummyenv", "dummyenv", "--yes")
c.Check(<-errc, gc.Equals, DoubleEnvironmentError)
// We treat --environment the same way
opc, errc = cmdtesting.RunCommand(cmdtesting.NullContext(c), new(DestroyEnvironmentCommand), "--environment", "dummyenv", "dummyenv", "--yes")
c.Check(<-errc, gc.Equals, DoubleEnvironmentError)
// destroy using the -e flag
opc, errc = cmdtesting.RunCommand(cmdtesting.NullContext(c), new(DestroyEnvironmentCommand), "-e", "dummyenv", "--yes")
c.Check(<-errc, gc.IsNil)
c.Check((<-opc).(dummy.OpDestroy).Env, gc.Equals, "dummyenv")
// Verify that the environment information has been removed.
_, err = s.ConfigStore.ReadInfo("dummyenv")
c.Assert(err, jc.Satisfies, errors.IsNotFound)
}
开发者ID:zhouqt,项目名称:juju,代码行数:25,代码来源:destroyenvironment_test.go
示例2: checkDestroyEnvironment
func (s *destroyEnvSuite) checkDestroyEnvironment(c *gc.C, blocked, force bool) {
//Setup environment
envName := "dummyenv"
s.startEnvironment(c, envName)
if blocked {
s.BlockDestroyEnvironment(c, "checkDestroyEnvironment")
}
opc := make(chan dummy.Operation)
errc := make(chan error)
if force {
opc, errc = cmdtesting.RunCommand(cmdtesting.NullContext(c), newDestroyEnvironmentCommand(), envName, "--yes", "--force")
} else {
opc, errc = cmdtesting.RunCommand(cmdtesting.NullContext(c), newDestroyEnvironmentCommand(), envName, "--yes")
}
if force || !blocked {
c.Check(<-errc, gc.IsNil)
c.Check((<-opc).(dummy.OpDestroy).Env, gc.Equals, envName)
// Verify that the environment information has been removed.
_, err := s.ConfigStore.ReadInfo(envName)
c.Assert(err, jc.Satisfies, errors.IsNotFound)
} else {
c.Check(<-errc, gc.Not(gc.IsNil))
c.Check((<-opc), gc.IsNil)
// Verify that the environment information has not been removed.
_, err := s.ConfigStore.ReadInfo(envName)
c.Assert(err, jc.ErrorIsNil)
}
}
开发者ID:snailwalker,项目名称:juju,代码行数:28,代码来源:destroyenvironment_test.go
示例3: TestDestroyEnvironmentCommandConfirmation
func (s *destroyEnvSuite) TestDestroyEnvironmentCommandConfirmation(c *gc.C) {
var stdin, stdout bytes.Buffer
ctx, err := cmd.DefaultContext()
c.Assert(err, gc.IsNil)
ctx.Stdout = &stdout
ctx.Stdin = &stdin
// Prepare the environment so we can destroy it.
env, err := environs.PrepareFromName("dummyenv", cmdtesting.NullContext(c), s.ConfigStore)
c.Assert(err, gc.IsNil)
assertEnvironNotDestroyed(c, env, s.ConfigStore)
// Ensure confirmation is requested if "-y" is not specified.
stdin.WriteString("n")
opc, errc := cmdtesting.RunCommand(ctx, new(DestroyEnvironmentCommand), "dummyenv")
c.Check(<-errc, gc.ErrorMatches, "environment destruction aborted")
c.Check(<-opc, gc.IsNil)
c.Check(stdout.String(), gc.Matches, "WARNING!.*dummyenv.*\\(type: dummy\\)(.|\n)*")
assertEnvironNotDestroyed(c, env, s.ConfigStore)
// EOF on stdin: equivalent to answering no.
stdin.Reset()
stdout.Reset()
opc, errc = cmdtesting.RunCommand(ctx, new(DestroyEnvironmentCommand), "dummyenv")
c.Check(<-opc, gc.IsNil)
c.Check(<-errc, gc.ErrorMatches, "environment destruction aborted")
assertEnvironNotDestroyed(c, env, s.ConfigStore)
// "--yes" passed: no confirmation request.
stdin.Reset()
stdout.Reset()
opc, errc = cmdtesting.RunCommand(ctx, new(DestroyEnvironmentCommand), "dummyenv", "--yes")
c.Check(<-errc, gc.IsNil)
c.Check((<-opc).(dummy.OpDestroy).Env, gc.Equals, "dummyenv")
c.Check(stdout.String(), gc.Equals, "")
assertEnvironDestroyed(c, env, s.ConfigStore)
// Any of casing of "y" and "yes" will confirm.
for _, answer := range []string{"y", "Y", "yes", "YES"} {
// Prepare the environment so we can destroy it.
s.Reset(c)
env, err := environs.PrepareFromName("dummyenv", cmdtesting.NullContext(c), s.ConfigStore)
c.Assert(err, gc.IsNil)
stdin.Reset()
stdout.Reset()
stdin.WriteString(answer)
opc, errc = cmdtesting.RunCommand(ctx, new(DestroyEnvironmentCommand), "dummyenv")
c.Check(<-errc, gc.IsNil)
c.Check((<-opc).(dummy.OpDestroy).Env, gc.Equals, "dummyenv")
c.Check(stdout.String(), gc.Matches, "WARNING!.*dummyenv.*\\(type: dummy\\)(.|\n)*")
assertEnvironDestroyed(c, env, s.ConfigStore)
}
}
开发者ID:zhouqt,项目名称:juju,代码行数:55,代码来源:destroyenvironment_test.go
示例4: TestDestroyCommandConfirmation
func (s *DestroySuite) TestDestroyCommandConfirmation(c *gc.C) {
var stdin, stdout bytes.Buffer
ctx, err := cmd.DefaultContext()
c.Assert(err, jc.ErrorIsNil)
ctx.Stdout = &stdout
ctx.Stdin = &stdin
// Ensure confirmation is requested if "-y" is not specified.
stdin.WriteString("n")
_, errc := cmdtesting.RunCommand(ctx, s.NewDestroyCommand(), "test2")
select {
case err := <-errc:
c.Check(err, gc.ErrorMatches, "environment destruction: aborted")
case <-time.After(testing.LongWait):
c.Fatalf("command took too long")
}
c.Check(testing.Stdout(ctx), gc.Matches, "WARNING!.*test2(.|\n)*")
checkEnvironmentExistsInStore(c, "test1", s.store)
// EOF on stdin: equivalent to answering no.
stdin.Reset()
stdout.Reset()
_, errc = cmdtesting.RunCommand(ctx, s.NewDestroyCommand(), "test2")
select {
case err := <-errc:
c.Check(err, gc.ErrorMatches, "environment destruction: aborted")
case <-time.After(testing.LongWait):
c.Fatalf("command took too long")
}
c.Check(testing.Stdout(ctx), gc.Matches, "WARNING!.*test2(.|\n)*")
checkEnvironmentExistsInStore(c, "test1", s.store)
for _, answer := range []string{"y", "Y", "yes", "YES"} {
stdin.Reset()
stdout.Reset()
stdin.WriteString(answer)
_, errc = cmdtesting.RunCommand(ctx, s.NewDestroyCommand(), "test2")
select {
case err := <-errc:
c.Check(err, jc.ErrorIsNil)
case <-time.After(testing.LongWait):
c.Fatalf("command took too long")
}
checkEnvironmentRemovedFromStore(c, "test2", s.store)
// Add the test2 environment back into the store for the next test
s.resetEnvironment(c)
}
}
开发者ID:imoapps,项目名称:juju,代码行数:49,代码来源:destroy_test.go
示例5: TestDestroyEnvironmentCommandTwiceOnNonStateServer
func (s *destroyEnvSuite) TestDestroyEnvironmentCommandTwiceOnNonStateServer(c *gc.C) {
s.setupHostedEnviron(c, "dummy-non-state-server")
oldInfo, err := s.ConfigStore.ReadInfo("dummy-non-state-server")
c.Assert(err, jc.ErrorIsNil)
opc, errc := cmdtesting.RunCommand(cmdtesting.NullContext(c), newDestroyEnvironmentCommand(), "dummy-non-state-server", "--yes")
c.Check(<-errc, gc.IsNil)
c.Check(<-opc, gc.IsNil)
_, err = s.ConfigStore.ReadInfo("dummy-non-state-server")
c.Assert(err, jc.Satisfies, errors.IsNotFound)
// Simluate another client calling destroy on the same environment. This
// client will have a local cache of the environ info, so write it back out.
info := s.ConfigStore.CreateInfo("dummy-non-state-server")
info.SetAPIEndpoint(oldInfo.APIEndpoint())
info.SetAPICredentials(oldInfo.APICredentials())
err = info.Write()
c.Assert(err, jc.ErrorIsNil)
// Call destroy again.
context, err := coretesting.RunCommand(c, newDestroyEnvironmentCommand(), "dummy-non-state-server", "--yes")
c.Assert(err, jc.ErrorIsNil)
c.Assert(coretesting.Stderr(context), gc.Equals, "environment not found, removing config file\n")
// Check that the client's cached info has been removed.
_, err = s.ConfigStore.ReadInfo("dummy-non-state-server")
c.Assert(err, jc.Satisfies, errors.IsNotFound)
}
开发者ID:snailwalker,项目名称:juju,代码行数:29,代码来源:destroyenvironment_test.go
示例6: TestBootstrapKeepBroken
func (s *BootstrapSuite) TestBootstrapKeepBroken(c *gc.C) {
resetJujuHome(c, "devenv")
devVersion := version.Current
// Force a dev version by having a non zero build number.
// This is because we have not uploaded any tools and auto
// upload is only enabled for dev versions.
devVersion.Build = 1234
s.PatchValue(&version.Current, devVersion)
opc, errc := cmdtesting.RunCommand(cmdtesting.NullContext(c), envcmd.Wrap(new(BootstrapCommand)), "-e", "brokenenv", "--keep-broken")
err := <-errc
c.Assert(err, gc.ErrorMatches, "failed to bootstrap environment: dummy.Bootstrap is broken")
done := false
for !done {
select {
case op, ok := <-opc:
if !ok {
done = true
break
}
switch op.(type) {
case dummy.OpDestroy:
c.Error("unexpected call to env.Destroy")
break
}
default:
break
}
}
}
开发者ID:kakamessi99,项目名称:juju,代码行数:29,代码来源:bootstrap_test.go
示例7: TestAutoUploadOnlyForDev
func (s *BootstrapSuite) TestAutoUploadOnlyForDev(c *gc.C) {
s.setupAutoUploadTest(c, "1.8.3", "precise")
_, errc := cmdtesting.RunCommand(cmdtesting.NullContext(c), envcmd.Wrap(new(BootstrapCommand)))
err := <-errc
c.Assert(err, gc.ErrorMatches,
"failed to bootstrap environment: Juju cannot bootstrap because no tools are available for your environment(.|\n)*")
}
开发者ID:kakamessi99,项目名称:juju,代码行数:7,代码来源:bootstrap_test.go
示例8: TestBootstrapDestroy
func (s *BootstrapSuite) TestBootstrapDestroy(c *gc.C) {
resetJujuHome(c, "devenv")
devVersion := version.Current
// Force a dev version by having a non zero build number.
// This is because we have not uploaded any tools and auto
// upload is only enabled for dev versions.
devVersion.Build = 1234
s.PatchValue(&version.Current, devVersion)
opc, errc := cmdtesting.RunCommand(cmdtesting.NullContext(c), envcmd.Wrap(new(BootstrapCommand)), "-e", "brokenenv")
err := <-errc
c.Assert(err, gc.ErrorMatches, "failed to bootstrap environment: dummy.Bootstrap is broken")
var opDestroy *dummy.OpDestroy
for opDestroy == nil {
select {
case op := <-opc:
switch op := op.(type) {
case dummy.OpDestroy:
opDestroy = &op
}
default:
c.Error("expected call to env.Destroy")
return
}
}
c.Assert(opDestroy.Error, gc.ErrorMatches, "dummy.Destroy is broken")
}
开发者ID:kakamessi99,项目名称:juju,代码行数:26,代码来源:bootstrap_test.go
示例9: TestDestroyEnvironmentCommandBroken
func (s *destroyEnvSuite) TestDestroyEnvironmentCommandBroken(c *gc.C) {
oldinfo, err := s.ConfigStore.ReadInfo("dummyenv")
c.Assert(err, gc.IsNil)
bootstrapConfig := oldinfo.BootstrapConfig()
apiEndpoint := oldinfo.APIEndpoint()
apiCredentials := oldinfo.APICredentials()
err = oldinfo.Destroy()
c.Assert(err, gc.IsNil)
newinfo := s.ConfigStore.CreateInfo("dummyenv")
bootstrapConfig["broken"] = "Destroy"
newinfo.SetBootstrapConfig(bootstrapConfig)
newinfo.SetAPIEndpoint(apiEndpoint)
newinfo.SetAPICredentials(apiCredentials)
err = newinfo.Write()
c.Assert(err, gc.IsNil)
// Prepare the environment so we can destroy it.
_, err = environs.PrepareFromName("dummyenv", cmdtesting.NullContext(c), s.ConfigStore)
c.Assert(err, gc.IsNil)
// destroy with broken environment
opc, errc := cmdtesting.RunCommand(cmdtesting.NullContext(c), new(DestroyEnvironmentCommand), "dummyenv", "--yes")
op, ok := (<-opc).(dummy.OpDestroy)
c.Assert(ok, jc.IsTrue)
c.Assert(op.Error, gc.ErrorMatches, "dummy.Destroy is broken")
c.Check(<-errc, gc.Equals, op.Error)
c.Check(<-opc, gc.IsNil)
}
开发者ID:zhouqt,项目名称:juju,代码行数:29,代码来源:destroyenvironment_test.go
示例10: TestBootstrapKeepBroken
func (s *BootstrapSuite) TestBootstrapKeepBroken(c *gc.C) {
resetJujuHome(c, "devenv")
s.patchVersion(c)
opc, errc := cmdtesting.RunCommand(cmdtesting.NullContext(c), newBootstrapCommand(), "-e", "brokenenv", "--keep-broken", "--auto-upgrade")
err := <-errc
c.Assert(err, gc.ErrorMatches, "failed to bootstrap environment: dummy.Bootstrap is broken")
done := false
for !done {
select {
case op, ok := <-opc:
if !ok {
done = true
break
}
switch op.(type) {
case dummy.OpDestroy:
c.Error("unexpected call to env.Destroy")
break
}
default:
break
}
}
}
开发者ID:imoapps,项目名称:juju,代码行数:25,代码来源:bootstrap_test.go
示例11: TestDestroyEnvironmentCommand
func (s *destroyEnvSuite) TestDestroyEnvironmentCommand(c *gc.C) {
// Prepare the environment so we can destroy it.
_, err := environs.PrepareFromName("dummyenv", cmdtesting.NullContext(c), s.ConfigStore)
c.Assert(err, gc.IsNil)
// check environment is mandatory
opc, errc := cmdtesting.RunCommand(cmdtesting.NullContext(c), new(DestroyEnvironmentCommand))
c.Check(<-errc, gc.Equals, NoEnvironmentError)
// normal destroy
opc, errc = cmdtesting.RunCommand(cmdtesting.NullContext(c), new(DestroyEnvironmentCommand), "dummyenv", "--yes")
c.Check(<-errc, gc.IsNil)
c.Check((<-opc).(dummy.OpDestroy).Env, gc.Equals, "dummyenv")
// Verify that the environment information has been removed.
_, err = s.ConfigStore.ReadInfo("dummyenv")
c.Assert(err, jc.Satisfies, errors.IsNotFound)
}
开发者ID:zhouqt,项目名称:juju,代码行数:18,代码来源:destroyenvironment_test.go
示例12: TestForceDestroyEnvironmentCommandOnNonStateServerNoConfimFails
func (s *destroyEnvSuite) TestForceDestroyEnvironmentCommandOnNonStateServerNoConfimFails(c *gc.C) {
s.setupHostedEnviron(c, "dummy-non-state-server")
opc, errc := cmdtesting.RunCommand(cmdtesting.NullContext(c), newDestroyEnvironmentCommand(), "dummy-non-state-server", "--force")
c.Check(<-errc, gc.ErrorMatches, "cannot force destroy environment without bootstrap information")
c.Check(<-opc, gc.IsNil)
serverInfo, err := s.ConfigStore.ReadInfo("dummy-non-state-server")
c.Assert(err, jc.ErrorIsNil)
c.Assert(serverInfo, gc.Not(gc.IsNil))
}
开发者ID:snailwalker,项目名称:juju,代码行数:10,代码来源:destroyenvironment_test.go
示例13: TestDestroyEnvironmentCommandNonStateServer
func (s *destroyEnvSuite) TestDestroyEnvironmentCommandNonStateServer(c *gc.C) {
s.setupHostedEnviron(c, "dummy-non-state-server")
opc, errc := cmdtesting.RunCommand(cmdtesting.NullContext(c), newDestroyEnvironmentCommand(), "dummy-non-state-server", "--yes")
c.Check(<-errc, gc.IsNil)
// Check that there are no operations on the provider, we do not want to call
// Destroy on it.
c.Check(<-opc, gc.IsNil)
_, err := s.ConfigStore.ReadInfo("dummy-non-state-server")
c.Assert(err, jc.Satisfies, errors.IsNotFound)
}
开发者ID:snailwalker,项目名称:juju,代码行数:11,代码来源:destroyenvironment_test.go
示例14: TestAutoUploadAfterFailedSync
func (s *BootstrapSuite) TestAutoUploadAfterFailedSync(c *gc.C) {
s.PatchValue(&version.Current.Series, config.LatestLtsSeries())
s.setupAutoUploadTest(c, "1.7.3", "quantal")
// Run command and check for that upload has been run for tools matching
// the current juju version.
opc, errc := cmdtesting.RunCommand(cmdtesting.NullContext(c), envcmd.Wrap(new(BootstrapCommand)), "-e", "devenv")
c.Assert(<-errc, gc.IsNil)
c.Check((<-opc).(dummy.OpBootstrap).Env, gc.Equals, "devenv")
icfg := (<-opc).(dummy.OpFinalizeBootstrap).InstanceConfig
c.Assert(icfg, gc.NotNil)
c.Assert(icfg.Tools.Version.String(), gc.Equals, "1.7.3.1-raring-"+arch.HostArch())
}
开发者ID:kakamessi99,项目名称:juju,代码行数:12,代码来源:bootstrap_test.go
示例15: TestDestroyEnvironmentCommandEmptyJenv
func (s *destroyEnvSuite) TestDestroyEnvironmentCommandEmptyJenv(c *gc.C) {
oldinfo, err := s.ConfigStore.ReadInfo("dummyenv")
info := s.ConfigStore.CreateInfo("dummy-no-bootstrap")
info.SetAPICredentials(oldinfo.APICredentials())
info.SetAPIEndpoint(oldinfo.APIEndpoint())
err = info.Write()
c.Assert(err, jc.ErrorIsNil)
opc, errc := cmdtesting.RunCommand(cmdtesting.NullContext(c), newDestroyEnvironmentCommand(), "dummy-no-bootstrap", "--yes")
c.Check(<-errc, gc.IsNil)
c.Check((<-opc).(dummy.OpDestroy).Env, gc.Equals, "dummyenv")
// Verify that the environment information has been removed.
_, err = s.ConfigStore.ReadInfo("dummyenv")
c.Assert(err, jc.Satisfies, errors.IsNotFound)
}
开发者ID:snailwalker,项目名称:juju,代码行数:16,代码来源:destroyenvironment_test.go
示例16: TestBootstrapJenvWarning
func (s *BootstrapSuite) TestBootstrapJenvWarning(c *gc.C) {
const envName = "devenv"
s.patchVersionAndSeries(c, envName)
store, err := configstore.Default()
c.Assert(err, jc.ErrorIsNil)
ctx := coretesting.Context(c)
environs.PrepareFromName(envName, envcmd.BootstrapContext(ctx), store)
logger := "jenv.warning.test"
var testWriter loggo.TestWriter
loggo.RegisterWriter(logger, &testWriter, loggo.WARNING)
defer loggo.RemoveWriter(logger)
_, errc := cmdtesting.RunCommand(ctx, newBootstrapCommand(), "-e", envName, "--auto-upgrade")
c.Assert(<-errc, gc.IsNil)
c.Assert(testWriter.Log(), jc.LogMatches, []string{"ignoring environments.yaml: using bootstrap config in .*"})
}
开发者ID:imoapps,项目名称:juju,代码行数:18,代码来源:bootstrap_test.go
示例17: TestKillCommandConfirmation
func (s *KillSuite) TestKillCommandConfirmation(c *gc.C) {
var stdin, stdout bytes.Buffer
ctx, err := cmd.DefaultContext()
c.Assert(err, jc.ErrorIsNil)
ctx.Stdout = &stdout
ctx.Stdin = &stdin
// Ensure confirmation is requested if "-y" is not specified.
stdin.WriteString("n")
_, errc := cmdtesting.RunCommand(ctx, s.newKillCommand(), "local.test1")
select {
case err := <-errc:
c.Check(err, gc.ErrorMatches, "controller destruction aborted")
case <-time.After(testing.LongWait):
c.Fatalf("command took too long")
}
c.Check(testing.Stdout(ctx), gc.Matches, "WARNING!.*local.test1(.|\n)*")
checkControllerExistsInStore(c, "local.test1", s.store)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:19,代码来源:kill_test.go
示例18: unregisterCommandAborts
func (s *UnregisterSuite) unregisterCommandAborts(c *gc.C, answer string) {
var stdin, stdout bytes.Buffer
ctx, err := cmd.DefaultContext()
c.Assert(err, jc.ErrorIsNil)
ctx.Stdout = &stdout
ctx.Stdin = &stdin
// Ensure confirmation is requested if "-y" is not specified.
stdin.WriteString(answer)
_, errc := cmdtesting.RunCommand(ctx, controller.NewUnregisterCommand(s.store), "fake1")
select {
case err, ok := <-errc:
c.Assert(ok, jc.IsTrue)
c.Check(err, gc.ErrorMatches, "unregistering controller: aborted")
case <-time.After(testing.LongWait):
c.Fatalf("command took too long")
}
c.Check(testing.Stdout(ctx), gc.Equals, unregisterMsg)
c.Check(s.store.lookupName, gc.Equals, "fake1")
c.Check(s.store.removedName, gc.Equals, "")
}
开发者ID:bac,项目名称:juju,代码行数:21,代码来源:unregister_test.go
示例19: unregisterCommandConfirms
func (s *UnregisterSuite) unregisterCommandConfirms(c *gc.C, answer string) {
var stdin, stdout bytes.Buffer
ctx, err := cmd.DefaultContext()
c.Assert(err, jc.ErrorIsNil)
ctx.Stdout = &stdout
ctx.Stdin = &stdin
stdin.Reset()
stdout.Reset()
stdin.WriteString(answer)
_, errc := cmdtesting.RunCommand(ctx, controller.NewUnregisterCommand(s.store), "fake1")
select {
case err, ok := <-errc:
c.Assert(ok, jc.IsTrue)
c.Check(err, jc.ErrorIsNil)
case <-time.After(testing.LongWait):
c.Fatalf("command took too long")
}
c.Check(s.store.lookupName, gc.Equals, "fake1")
c.Check(s.store.removedName, gc.Equals, "fake1")
}
开发者ID:bac,项目名称:juju,代码行数:21,代码来源:unregister_test.go
示例20: TestBootstrapCleansUpIfEnvironPrepFails
func (s *BootstrapSuite) TestBootstrapCleansUpIfEnvironPrepFails(c *gc.C) {
cleanupRan := false
s.PatchValue(&environType, func(string) (string, error) { return "", nil })
s.PatchValue(
&environFromName,
func(
*cmd.Context,
string,
string,
func(environs.Environ) error,
) (environs.Environ, func(), error) {
return nil, func() { cleanupRan = true }, fmt.Errorf("mock")
},
)
ctx := coretesting.Context(c)
_, errc := cmdtesting.RunCommand(ctx, newBootstrapCommand(), "-m", "peckham")
c.Check(<-errc, gc.Not(gc.IsNil))
c.Check(cleanupRan, jc.IsTrue)
}
开发者ID:pmatulis,项目名称:juju,代码行数:21,代码来源:bootstrap_test.go
注:本文中的github.com/juju/juju/cmd/testing.RunCommand函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论