當前位置: 首頁>>代碼示例>>Golang>>正文


Golang RecordingFs.HasAction方法代碼示例

本文整理匯總了Golang中github.com/tsuru/tsuru/fs/testing.RecordingFs.HasAction方法的典型用法代碼示例。如果您正苦於以下問題:Golang RecordingFs.HasAction方法的具體用法?Golang RecordingFs.HasAction怎麽用?Golang RecordingFs.HasAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/tsuru/tsuru/fs/testing.RecordingFs的用法示例。


在下文中一共展示了RecordingFs.HasAction方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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())
}
開發者ID:renanoliveira,項目名稱:tsuru,代碼行數:33,代碼來源:plugin_test.go

示例2: 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

示例3: 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.HasAction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。