本文整理汇总了Golang中github.com/tsuru/tsuru/fs/testing.RecordingFs.Open方法的典型用法代码示例。如果您正苦于以下问题:Golang RecordingFs.Open方法的具体用法?Golang RecordingFs.Open怎么用?Golang RecordingFs.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tsuru/tsuru/fs/testing.RecordingFs
的用法示例。
在下文中一共展示了RecordingFs.Open方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestPluginInstall
func (s *S) TestPluginInstall(c *gocheck.C) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "fakeplugin")
}))
defer ts.Close()
rfs := ftesting.RecordingFs{}
fsystem = &rfs
defer func() {
fsystem = nil
}()
var stdout bytes.Buffer
context := cmd.Context{
Args: []string{"myplugin", ts.URL},
Stdout: &stdout,
}
client := cmd.NewClient(nil, nil, manager)
command := pluginInstall{}
err := command.Run(&context, client)
c.Assert(err, gocheck.IsNil)
pluginsPath := cmd.JoinWithUserDir(".tsuru", "plugins")
hasAction := rfs.HasAction(fmt.Sprintf("mkdirall %s with mode 0755", pluginsPath))
c.Assert(hasAction, gocheck.Equals, true)
pluginPath := cmd.JoinWithUserDir(".tsuru", "plugins", "myplugin")
hasAction = rfs.HasAction(fmt.Sprintf("openfile %s with mode 0755", pluginPath))
c.Assert(hasAction, gocheck.Equals, true)
f, err := rfs.Open(pluginPath)
c.Assert(err, gocheck.IsNil)
data, err := ioutil.ReadAll(f)
c.Assert(err, gocheck.IsNil)
c.Assert("fakeplugin\n", gocheck.Equals, string(data))
expected := `Plugin "myplugin" successfully installed!` + "\n"
c.Assert(expected, gocheck.Equals, stdout.String())
}