本文整理匯總了Golang中github.com/tsuru/tsuru/exec/testing.FakeExecutor類的典型用法代碼示例。如果您正苦於以下問題:Golang FakeExecutor類的具體用法?Golang FakeExecutor怎麽用?Golang FakeExecutor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了FakeExecutor類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestPluginLookup
func (s *S) TestPluginLookup(c *gocheck.C) {
fexec := etesting.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{}), gocheck.Equals, true)
}
示例2: TestOpen
func (s *S) TestOpen(c *gocheck.C) {
fexec := etesting.FakeExecutor{}
execut = &fexec
defer func() {
execut = nil
}()
url := "http://someurl"
err := open(url)
c.Assert(err, gocheck.IsNil)
if runtime.GOOS == "linux" {
c.Assert(fexec.ExecutedCmd("xdg-open", []string{url}), gocheck.Equals, true)
} else {
c.Assert(fexec.ExecutedCmd("open", []string{url}), gocheck.Equals, true)
}
}
示例3: TestPluginWithArgs
func (s *S) TestPluginWithArgs(c *gocheck.C) {
fexec := etesting.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, gocheck.IsNil)
pluginPath := cmd.JoinWithUserDir(".tsuru", "plugins", "myplugin")
c.Assert(fexec.ExecutedCmd(pluginPath, []string{"ble", "bla"}), gocheck.Equals, true)
}
示例4: TestPlugin
func (s *S) TestPlugin(c *gocheck.C) {
fexec := etesting.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, gocheck.IsNil)
pluginPath := cmd.JoinWithUserDir(".tsuru", "plugins", "myplugin")
c.Assert(fexec.ExecutedCmd(pluginPath, []string{"a", "b"}), gocheck.Equals, true)
c.Assert(buf.String(), gocheck.Equals, "hello world")
}