本文整理汇总了Golang中github.com/tsuru/tsuru/exec/exectest.FakeExecutor.GetCommands方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeExecutor.GetCommands方法的具体用法?Golang FakeExecutor.GetCommands怎么用?Golang FakeExecutor.GetCommands使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tsuru/tsuru/exec/exectest.FakeExecutor
的用法示例。
在下文中一共展示了FakeExecutor.GetCommands方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestPlugin
func (s *S) TestPlugin(c *check.C) {
fexec := exectest.FakeExecutor{
Output: map[string][][]byte{
"a b": {[]byte("hello world")},
},
}
execut = &fexec
defer func() {
execut = nil
}()
var buf bytes.Buffer
context := cmd.Context{
Args: []string{"myplugin", "a", "b"},
Stdout: &buf,
Stderr: &buf,
}
client := cmd.NewClient(nil, nil, manager)
command := plugin{}
err := command.Run(&context, client)
c.Assert(err, check.IsNil)
pluginPath := cmd.JoinWithUserDir(".tsuru", "plugins", "myplugin")
c.Assert(fexec.ExecutedCmd(pluginPath, []string{"a", "b"}), check.Equals, true)
c.Assert(buf.String(), check.Equals, "hello world")
commands := fexec.GetCommands(pluginPath)
c.Assert(commands, check.HasLen, 1)
target, err := cmd.ReadTarget()
c.Assert(err, check.IsNil)
token, err := cmd.ReadToken()
c.Assert(err, check.IsNil)
envs := os.Environ()
tsuruEnvs := []string{
fmt.Sprintf("TSURU_TARGET=%s/", target),
fmt.Sprintf("TSURU_TOKEN=%s", token),
"TSURU_PLUGIN_NAME=myplugin",
}
envs = append(envs, tsuruEnvs...)
c.Assert(commands[0].GetEnvs(), check.DeepEquals, envs)
}