本文整理汇总了Golang中github.com/tsuru/tsuru/fs/testing.RecordingFs类的典型用法代码示例。如果您正苦于以下问题:Golang RecordingFs类的具体用法?Golang RecordingFs怎么用?Golang RecordingFs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RecordingFs类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestGetSSHCommandsDefaultKeyFile
func (s *S) TestGetSSHCommandsDefaultKeyFile(c *gocheck.C) {
rfs := ftesting.RecordingFs{}
f, err := rfs.Create(os.ExpandEnv("${HOME}/.ssh/id_rsa.pub"))
c.Assert(err, gocheck.IsNil)
f.Write([]byte("ssh-rsa ohwait! [email protected]"))
f.Close()
old := fsystem
fsystem = &rfs
defer func() {
fsystem = old
}()
commands, err := sshCmds()
c.Assert(err, gocheck.IsNil)
c.Assert(commands[0], gocheck.Equals, "/var/lib/tsuru/add-key ssh-rsa ohwait! [email protected]")
}
开发者ID:ningjh,项目名称:tsuru,代码行数:15,代码来源:docker_test.go
示例2: TestGetSSHCommandsDefaultSSHDPath
func (s *S) TestGetSSHCommandsDefaultSSHDPath(c *gocheck.C) {
rfs := ftesting.RecordingFs{}
f, err := rfs.Create("/opt/me/id_dsa.pub")
c.Assert(err, gocheck.IsNil)
f.Write([]byte("ssh-rsa ohwait! [email protected]"))
f.Close()
old := fsystem
fsystem = &rfs
defer func() {
fsystem = old
}()
config.Set("docker:ssh:public-key", "/opt/me/id_dsa.pub")
defer config.Unset("docker:ssh:public-key")
commands, err := sshCmds()
c.Assert(err, gocheck.IsNil)
c.Assert(commands[1], gocheck.Equals, "sudo /usr/sbin/sshd -D")
}
开发者ID:ningjh,项目名称:tsuru,代码行数:17,代码来源:docker_test.go
示例3: 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())
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:33,代码来源:plugin_test.go
示例4: TestKeyAddSpecifyingKeyFile
func (s *S) TestKeyAddSpecifyingKeyFile(c *gocheck.C) {
var stdout, stderr bytes.Buffer
u, err := user.Current()
c.Assert(err, gocheck.IsNil)
p := path.Join(u.HomeDir, ".ssh", "id_dsa.pub")
expected := fmt.Sprintf("Key %q successfully added!\n", p)
context := cmd.Context{
Args: []string{p},
Stdout: &stdout,
Stderr: &stderr,
}
client := cmd.NewClient(&http.Client{Transport: &testing.Transport{Message: "success", Status: http.StatusOK}}, nil, manager)
fs := fs_test.RecordingFs{FileContent: "user-key"}
command := KeyAdd{keyReader{fsystem: &fs}}
err = command.Run(&context, client)
c.Assert(err, gocheck.IsNil)
c.Assert(stdout.String(), gocheck.Equals, expected)
c.Assert(fs.HasAction("open "+p), gocheck.Equals, true)
}
开发者ID:ningjh,项目名称:tsuru,代码行数:19,代码来源:key_test.go
示例5: TestPluginRemove
func (s *S) TestPluginRemove(c *gocheck.C) {
rfs := ftesting.RecordingFs{}
fsystem = &rfs
defer func() {
fsystem = nil
}()
var stdout bytes.Buffer
context := cmd.Context{
Args: []string{"myplugin"},
Stdout: &stdout,
}
client := cmd.NewClient(nil, nil, manager)
command := pluginRemove{}
err := command.Run(&context, client)
c.Assert(err, gocheck.IsNil)
pluginPath := cmd.JoinWithUserDir(".tsuru", "plugins", "myplugin")
hasAction := rfs.HasAction(fmt.Sprintf("remove %s", pluginPath))
c.Assert(hasAction, gocheck.Equals, true)
expected := `Plugin "myplugin" successfully removed!` + "\n"
c.Assert(expected, gocheck.Equals, stdout.String())
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:21,代码来源:plugin_test.go
注:本文中的github.com/tsuru/tsuru/fs/testing.RecordingFs类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论