本文整理汇总了Golang中github.com/wallyworld/core/testing.Stderr函数的典型用法代码示例。如果您正苦于以下问题:Golang Stderr函数的具体用法?Golang Stderr怎么用?Golang Stderr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Stderr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestResolved
func (s *retryProvisioningSuite) TestResolved(c *gc.C) {
m, err := s.State.AddOneMachine(state.MachineTemplate{
Series: "quantal",
Jobs: []state.MachineJob{state.JobManageEnviron},
})
c.Assert(err, gc.IsNil)
err = m.SetStatus(params.StatusError, "broken", nil)
c.Assert(err, gc.IsNil)
_, err = s.State.AddOneMachine(state.MachineTemplate{
Series: "quantal",
Jobs: []state.MachineJob{state.JobHostUnits},
})
c.Assert(err, gc.IsNil)
for i, t := range resolvedMachineTests {
c.Logf("test %d: %v", i, t.args)
context, err := testing.RunCommand(c, &RetryProvisioningCommand{}, t.args)
if t.err != "" {
c.Check(err, gc.ErrorMatches, t.err)
continue
} else {
c.Check(err, gc.IsNil)
}
output := testing.Stderr(context)
stripped := strings.Replace(output, "\n", "", -1)
c.Check(stripped, gc.Equals, t.stdErr)
if t.args[0] == "0" {
status, info, data, err := m.Status()
c.Check(err, gc.IsNil)
c.Check(status, gc.Equals, params.StatusError)
c.Check(info, gc.Equals, "broken")
c.Check(data["transient"], jc.IsTrue)
}
}
}
开发者ID:jameinel,项目名称:core,代码行数:35,代码来源:retryprovisioning_test.go
示例2: TestWaitSSHKilledWaitingForAddresses
func (s *BootstrapSuite) TestWaitSSHKilledWaitingForAddresses(c *gc.C) {
ctx := coretesting.Context(c)
interrupted := make(chan os.Signal, 1)
interrupted <- os.Interrupt
_, err := common.WaitSSH(ctx, interrupted, ssh.DefaultClient, "/bin/true", neverAddresses{}, testSSHTimeout)
c.Check(err, gc.ErrorMatches, "interrupted")
c.Check(coretesting.Stderr(ctx), gc.Matches, "Waiting for address\n")
}
开发者ID:jameinel,项目名称:core,代码行数:8,代码来源:bootstrap_test.go
示例3: TestRunPluginWithFailing
func (suite *PluginSuite) TestRunPluginWithFailing(c *gc.C) {
suite.makeFailingPlugin("foo", 2)
ctx := testing.Context(c)
err := RunPlugin(ctx, "foo", []string{"some params"})
c.Assert(err, gc.ErrorMatches, "exit status 2")
c.Assert(testing.Stdout(ctx), gc.Equals, "failing\n")
c.Assert(testing.Stderr(ctx), gc.Equals, "")
}
开发者ID:jameinel,项目名称:core,代码行数:8,代码来源:plugin_test.go
示例4: TestRunPluginExising
func (suite *PluginSuite) TestRunPluginExising(c *gc.C) {
suite.makePlugin("foo", 0755)
ctx := testing.Context(c)
err := RunPlugin(ctx, "foo", []string{"some params"})
c.Assert(err, gc.IsNil)
c.Assert(testing.Stdout(ctx), gc.Equals, "foo some params\n")
c.Assert(testing.Stderr(ctx), gc.Equals, "")
}
开发者ID:jameinel,项目名称:core,代码行数:8,代码来源:plugin_test.go
示例5: TestStderr
func (s *LogSuite) TestStderr(c *gc.C) {
l := &cmd.Log{ShowLog: true, Config: "<root>=INFO"}
ctx := coretesting.Context(c)
err := l.Start(ctx)
c.Assert(err, gc.IsNil)
logger.Infof("hello")
c.Assert(coretesting.Stderr(ctx), gc.Matches, `^.* INFO .* hello\n`)
}
开发者ID:jameinel,项目名称:core,代码行数:8,代码来源:logging_test.go
示例6: TestImportKeys
func (s *ImportKeySuite) TestImportKeys(c *gc.C) {
key1 := sshtesting.ValidKeyOne.Key + " [email protected]"
s.setAuthorizedKeys(c, key1)
context, err := coretesting.RunCommand(c, &ImportKeysCommand{}, []string{"lp:validuser", "invalid-key"})
c.Assert(err, gc.IsNil)
c.Assert(coretesting.Stderr(context), gc.Matches, `cannot import key id "invalid-key".*\n`)
s.assertEnvironKeys(c, key1, sshtesting.ValidKeyThree.Key)
}
开发者ID:jameinel,项目名称:core,代码行数:9,代码来源:authorizedkeys_test.go
示例7: TestDestroyEnvironmentCommandEmptyJenv
func (s *destroyEnvSuite) TestDestroyEnvironmentCommandEmptyJenv(c *gc.C) {
_, err := s.ConfigStore.CreateInfo("emptyenv")
c.Assert(err, gc.IsNil)
context, err := coretesting.RunCommand(c, new(DestroyEnvironmentCommand), []string{"-e", "emptyenv"})
c.Assert(err, gc.IsNil)
c.Assert(coretesting.Stderr(context), gc.Equals, "removing empty environment file\n")
}
开发者ID:jameinel,项目名称:core,代码行数:9,代码来源:destroyenvironment_test.go
示例8: TestWaitSSHTimesOutWaitingForDial
func (s *BootstrapSuite) TestWaitSSHTimesOutWaitingForDial(c *gc.C) {
ctx := coretesting.Context(c)
// 0.x.y.z addresses are always invalid
_, err := common.WaitSSH(ctx, nil, ssh.DefaultClient, "/bin/true", &neverOpensPort{addr: "0.1.2.3"}, testSSHTimeout)
c.Check(err, gc.ErrorMatches,
`waited for `+testSSHTimeout.Timeout.String()+` without being able to connect: mock connection failure to 0.1.2.3`)
c.Check(coretesting.Stderr(ctx), gc.Matches,
"Waiting for address\n"+
"(Attempting to connect to 0.1.2.3:22\n)+")
}
开发者ID:jameinel,项目名称:core,代码行数:10,代码来源:bootstrap_test.go
示例9: TestUpgradeReportsDeprecated
func (s *DeploySuite) TestUpgradeReportsDeprecated(c *gc.C) {
coretesting.Charms.ClonedDirPath(s.SeriesPath, "dummy")
ctx, err := coretesting.RunCommand(c, &DeployCommand{}, []string{"local:dummy", "-u"})
c.Assert(err, gc.IsNil)
c.Assert(coretesting.Stdout(ctx), gc.Equals, "")
output := strings.Split(coretesting.Stderr(ctx), "\n")
c.Check(output[0], gc.Matches, `Added charm ".*" to the environment.`)
c.Check(output[1], gc.Equals, "--upgrade (or -u) is deprecated and ignored; charms are always deployed with a unique revision.")
}
开发者ID:jameinel,项目名称:core,代码行数:10,代码来源:deploy_test.go
示例10: TestRunning
func (s *RunTestSuite) TestRunning(c *gc.C) {
loggo.GetLogger("worker.uniter").SetLogLevel(loggo.TRACE)
s.runListenerForAgent(c, "foo")
ctx, err := testing.RunCommand(c, &RunCommand{}, []string{"foo", "bar"})
c.Check(cmd.IsRcPassthroughError(err), jc.IsTrue)
c.Assert(err, gc.ErrorMatches, "subprocess encountered error code 42")
c.Assert(testing.Stdout(ctx), gc.Equals, "bar stdout")
c.Assert(testing.Stderr(ctx), gc.Equals, "bar stderr")
}
开发者ID:jameinel,项目名称:core,代码行数:10,代码来源:run_test.go
示例11: TestShowLogSetsLogLevel
func (s *LogSuite) TestShowLogSetsLogLevel(c *gc.C) {
l := &cmd.Log{ShowLog: true}
ctx := coretesting.Context(c)
err := l.Start(ctx)
c.Assert(err, gc.IsNil)
c.Assert(loggo.GetLogger("").LogLevel(), gc.Equals, loggo.INFO)
c.Assert(coretesting.Stderr(ctx), gc.Equals, "")
c.Assert(coretesting.Stdout(ctx), gc.Equals, "")
}
开发者ID:jameinel,项目名称:core,代码行数:10,代码来源:logging_test.go
示例12: TestAddKey
func (s *AddKeySuite) TestAddKey(c *gc.C) {
key1 := sshtesting.ValidKeyOne.Key + " [email protected]"
s.setAuthorizedKeys(c, key1)
key2 := sshtesting.ValidKeyTwo.Key + " [email protected]"
context, err := coretesting.RunCommand(c, &AddKeysCommand{}, []string{key2, "invalid-key"})
c.Assert(err, gc.IsNil)
c.Assert(coretesting.Stderr(context), gc.Matches, `cannot add key "invalid-key".*\n`)
s.assertEnvironKeys(c, key1, key2)
}
开发者ID:jameinel,项目名称:core,代码行数:10,代码来源:authorizedkeys_test.go
示例13: TestRunDeprecationWarning
func (s *RelationSetSuite) TestRunDeprecationWarning(c *gc.C) {
hctx := s.GetHookContext(c, 0, "")
com, _ := jujuc.NewCommand(hctx, "relation-set")
// The rel= is needed to make this a valid command.
ctx, err := testing.RunCommand(c, com, []string{"--format", "foo", "rel="})
c.Assert(err, gc.IsNil)
c.Assert(testing.Stdout(ctx), gc.Equals, "")
c.Assert(testing.Stderr(ctx), gc.Equals, "--format flag deprecated for command \"relation-set\"")
}
开发者ID:jameinel,项目名称:core,代码行数:10,代码来源:relation-set_test.go
示例14: TestOutputQuiet
func (s *LogSuite) TestOutputQuiet(c *gc.C) {
l := &cmd.Log{Quiet: true}
ctx := coretesting.Context(c)
err := l.Start(ctx)
c.Assert(err, gc.IsNil)
ctx.Infof("Writing info output")
ctx.Verbosef("Writing verbose output")
c.Assert(coretesting.Stderr(ctx), gc.Equals, "")
}
开发者ID:jameinel,项目名称:core,代码行数:11,代码来源:logging_test.go
示例15: TestImportKeyNonDefaultUser
func (s *ImportKeySuite) TestImportKeyNonDefaultUser(c *gc.C) {
key1 := sshtesting.ValidKeyOne.Key + " [email protected]"
s.setAuthorizedKeys(c, key1)
_, err := s.State.AddUser("fred", "password")
c.Assert(err, gc.IsNil)
context, err := coretesting.RunCommand(c, &ImportKeysCommand{}, []string{"--user", "fred", "lp:validuser"})
c.Assert(err, gc.IsNil)
c.Assert(coretesting.Stderr(context), gc.Equals, "")
s.assertEnvironKeys(c, key1, sshtesting.ValidKeyThree.Key)
}
开发者ID:jameinel,项目名称:core,代码行数:11,代码来源:authorizedkeys_test.go
示例16: TestDeleteKeys
func (s *DeleteKeySuite) TestDeleteKeys(c *gc.C) {
key1 := sshtesting.ValidKeyOne.Key + " [email protected]"
key2 := sshtesting.ValidKeyTwo.Key + " [email protected]"
s.setAuthorizedKeys(c, key1, key2)
context, err := coretesting.RunCommand(
c, &DeleteKeysCommand{}, []string{sshtesting.ValidKeyTwo.Fingerprint, "invalid-key"})
c.Assert(err, gc.IsNil)
c.Assert(coretesting.Stderr(context), gc.Matches, `cannot delete key id "invalid-key".*\n`)
s.assertEnvironKeys(c, key1)
}
开发者ID:jameinel,项目名称:core,代码行数:11,代码来源:authorizedkeys_test.go
示例17: TestMissingCallbackErrors
func (s *SuperCommandSuite) TestMissingCallbackErrors(c *gc.C) {
callback := func(ctx *cmd.Context, subcommand string, args []string) error {
return fmt.Errorf("command not found %q", subcommand)
}
ctx := testing.Context(c)
code := cmd.Main(NewSuperWithCallback(callback), ctx, []string{"foo"})
c.Assert(code, gc.Equals, 1)
c.Assert(testing.Stdout(ctx), gc.Equals, "")
c.Assert(testing.Stderr(ctx), gc.Equals, "ERROR command not found \"foo\"\n")
}
开发者ID:jameinel,项目名称:core,代码行数:11,代码来源:supercommand_test.go
示例18: TestOutputDebugForcesQuiet
func (s *LogSuite) TestOutputDebugForcesQuiet(c *gc.C) {
l := &cmd.Log{Verbose: true, Debug: true}
ctx := coretesting.Context(c)
err := l.Start(ctx)
c.Assert(err, gc.IsNil)
ctx.Infof("Writing info output")
ctx.Verbosef("Writing verbose output")
c.Assert(coretesting.Stderr(ctx), gc.Matches, `^.*INFO .* Writing info output\n.*INFO .*Writing verbose output\n.*`)
}
开发者ID:jameinel,项目名称:core,代码行数:11,代码来源:logging_test.go
示例19: TestSingleResponse
func (s *RunSuite) TestSingleResponse(c *gc.C) {
mock := s.setupMockAPI()
mock.setMachinesAlive("0")
mockResponse := mockResponse{
stdout: "stdout\n",
stderr: "stderr\n",
code: 42,
machineId: "0",
}
mock.setResponse("0", mockResponse)
unformatted := ConvertRunResults([]params.RunResult{
makeRunResult(mockResponse)})
yamlFormatted, err := cmd.FormatYaml(unformatted)
c.Assert(err, gc.IsNil)
jsonFormatted, err := cmd.FormatJson(unformatted)
c.Assert(err, gc.IsNil)
for i, test := range []struct {
message string
format string
stdout string
stderr string
errorMatch string
}{{
message: "smart (default)",
stdout: "stdout\n",
stderr: "stderr\n",
errorMatch: "subprocess encountered error code 42",
}, {
message: "yaml output",
format: "yaml",
stdout: string(yamlFormatted) + "\n",
}, {
message: "json output",
format: "json",
stdout: string(jsonFormatted) + "\n",
}} {
c.Log(fmt.Sprintf("%v: %s", i, test.message))
args := []string{}
if test.format != "" {
args = append(args, "--format", test.format)
}
args = append(args, "--all", "ignored")
context, err := testing.RunCommand(c, &RunCommand{}, args)
if test.errorMatch != "" {
c.Check(err, gc.ErrorMatches, test.errorMatch)
} else {
c.Check(err, gc.IsNil)
}
c.Check(testing.Stdout(context), gc.Equals, test.stdout)
c.Check(testing.Stderr(context), gc.Equals, test.stderr)
}
}
开发者ID:jameinel,项目名称:core,代码行数:53,代码来源:run_test.go
示例20: TestAddKeyNonDefaultUser
func (s *AddKeySuite) TestAddKeyNonDefaultUser(c *gc.C) {
key1 := sshtesting.ValidKeyOne.Key + " [email protected]"
s.setAuthorizedKeys(c, key1)
_, err := s.State.AddUser("fred", "password")
c.Assert(err, gc.IsNil)
key2 := sshtesting.ValidKeyTwo.Key + " [email protected]"
context, err := coretesting.RunCommand(c, &AddKeysCommand{}, []string{"--user", "fred", key2})
c.Assert(err, gc.IsNil)
c.Assert(coretesting.Stderr(context), gc.Equals, "")
s.assertEnvironKeys(c, key1, key2)
}
开发者ID:jameinel,项目名称:core,代码行数:12,代码来源:authorizedkeys_test.go
注:本文中的github.com/wallyworld/core/testing.Stderr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论