本文整理汇总了Golang中github.com/wallyworld/core/testing.Stderr函数的典型用法代码示例。如果您正苦于以下问题:Golang Stderr函数的具体用法?Golang Stderr怎么用?Golang Stderr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Stderr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
}
}
}
示例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")
}
示例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, "")
}
示例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, "")
}
示例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`)
}
示例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)
}
示例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")
}
示例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)+")
}
示例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.")
}
示例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")
}
示例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, "")
}
示例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)
}
示例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\"")
}
示例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, "")
}
示例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)
}