本文整理汇总了Golang中github.com/tsuru/tsuru/exec/exectest.FakeExecutor类的典型用法代码示例。如果您正苦于以下问题:Golang FakeExecutor类的具体用法?Golang FakeExecutor怎么用?Golang FakeExecutor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FakeExecutor类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestPluginLookup
func (s *S) TestPluginLookup(c *check.C) {
fexec := exectest.FakeExecutor{}
execut = &fexec
defer func() {
execut = nil
}()
manager := buildManager("tsuru")
manager.Run([]string{"myplugin"})
pluginPath := cmd.JoinWithUserDir(".tsuru", "plugins", "myplugin")
c.Assert(fexec.ExecutedCmd(pluginPath, []string{}), check.Equals, true)
}
开发者ID:pauloalem,项目名称:tsuru-client,代码行数:11,代码来源:main_test.go
示例2: TestOpen
func (s *S) TestOpen(c *check.C) {
fexec := exectest.FakeExecutor{}
execut = &fexec
defer func() {
execut = nil
}()
url := "http://someurl"
err := open(url)
c.Assert(err, check.IsNil)
if runtime.GOOS == "linux" {
c.Assert(fexec.ExecutedCmd("xdg-open", []string{url}), check.Equals, true)
} else {
c.Assert(fexec.ExecutedCmd("open", []string{url}), check.Equals, true)
}
}
开发者ID:4eek,项目名称:tsuru,代码行数:15,代码来源:oauth_test.go
示例3: TestPluginWithArgs
func (s *S) TestPluginWithArgs(c *check.C) {
fexec := exectest.FakeExecutor{}
execut = &fexec
defer func() {
execut = nil
}()
context := cmd.Context{
Args: []string{"myplugin", "ble", "bla"},
}
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{"ble", "bla"}), check.Equals, true)
}
开发者ID:wpjunior,项目名称:tsuru-client,代码行数:16,代码来源:plugin_test.go
示例4: 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)
}
开发者ID:wpjunior,项目名称:tsuru-client,代码行数:38,代码来源:plugin_test.go
注:本文中的github.com/tsuru/tsuru/exec/exectest.FakeExecutor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论