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


Golang testing.ContextForDir函數代碼示例

本文整理匯總了Golang中github.com/juju/juju/testing.ContextForDir函數的典型用法代碼示例。如果您正苦於以下問題:Golang ContextForDir函數的具體用法?Golang ContextForDir怎麽用?Golang ContextForDir使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ContextForDir函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: assertSetWarning

func (s *SetSuite) assertSetWarning(c *gc.C, dir string, args []string, w string) {
	ctx := coretesting.ContextForDir(c, dir)
	code := cmd.Main(service.NewSetCommandWithAPI(s.fakeClientAPI, s.fakeServiceAPI), ctx, append([]string{"dummy-service"}, args...))
	c.Check(code, gc.Equals, 0)

	c.Assert(strings.Replace(c.GetTestLog(), "\n", " ", -1), gc.Matches, ".*WARNING.*"+w+".*")
}
開發者ID:imoapps,項目名稱:juju,代碼行數:7,代碼來源:set_test.go

示例2: assertSetWarning

func (s *configCommandSuite) assertSetWarning(c *gc.C, dir string, args []string, w string) {
	ctx := coretesting.ContextForDir(c, dir)
	code := cmd.Main(application.NewConfigCommandForTest(s.fake), ctx, append([]string{"dummy-application"}, args...))
	c.Check(code, gc.Equals, 0)

	c.Assert(strings.Replace(c.GetTestLog(), "\n", " ", -1), gc.Matches, ".*WARNING.*"+w+".*")
}
開發者ID:bac,項目名稱:juju,代碼行數:7,代碼來源:config_test.go

示例3: setupConfigFile

// setupConfigFile creates a configuration file for testing set
// with the --config argument specifying a configuration file.
func setupConfigFile(c *gc.C, dir string) string {
	ctx := coretesting.ContextForDir(c, dir)
	path := ctx.AbsPath("testconfig.yaml")
	content := []byte(yamlConfigValue)
	err := ioutil.WriteFile(path, content, 0666)
	c.Assert(err, jc.ErrorIsNil)
	return path
}
開發者ID:imoapps,項目名稱:juju,代碼行數:10,代碼來源:set_test.go

示例4: setupConfigFile

// setupConfigFile creates a configuration file for testing set
// with the --config argument specifying a configuration file.
func setupConfigFile(c *gc.C, dir string) string {
	ctx := coretesting.ContextForDir(c, dir)
	path := ctx.AbsPath("testconfig.yaml")
	content := []byte("dummy-service:\n  skill-level: 9000\n  username: admin001\n\n")
	err := ioutil.WriteFile(path, content, 0666)
	c.Assert(err, jc.ErrorIsNil)
	return path
}
開發者ID:snailwalker,項目名稱:juju,代碼行數:10,代碼來源:deploy_test.go

示例5: setupValueFile

// setupValueFile creates a file containing one value for testing
// set with [email protected]
func setupValueFile(c *gc.C, dir, filename, value string) string {
	ctx := coretesting.ContextForDir(c, dir)
	path := ctx.AbsPath(filename)
	content := []byte(value)
	err := ioutil.WriteFile(path, content, 0666)
	c.Assert(err, gc.IsNil)
	return path
}
開發者ID:klyachin,項目名稱:juju,代碼行數:10,代碼來源:set_test.go

示例6: assertSetSuccess

// assertSetSuccess sets configuration options and checks the expected settings.
func assertSetSuccess(c *gc.C, dir string, svc *state.Service, args []string, expect charm.Settings) {
	ctx := coretesting.ContextForDir(c, dir)
	code := cmd.Main(envcmd.Wrap(&SetCommand{}), ctx, append([]string{"dummy-service"}, args...))
	c.Check(code, gc.Equals, 0)
	settings, err := svc.ConfigSettings()
	c.Assert(err, gc.IsNil)
	c.Assert(settings, gc.DeepEquals, expect)
}
開發者ID:klyachin,項目名稱:juju,代碼行數:9,代碼來源:set_test.go

示例7: TestBlockUnset

func (s *UnsetSuite) TestBlockUnset(c *gc.C) {
	// Block operation
	s.fake.err = common.ErrOperationBlocked("TestBlockUnset")
	ctx := coretesting.ContextForDir(c, s.dir)
	code := cmd.Main(envcmd.Wrap(service.NewUnsetCommand(s.fake)), ctx, []string{
		"dummy-service",
		"username"})
	c.Check(code, gc.Equals, 1)

	// msg is logged
	stripped := strings.Replace(c.GetTestLog(), "\n", "", -1)
	c.Check(stripped, gc.Matches, ".*TestBlockUnset.*")
}
開發者ID:Pankov404,項目名稱:juju,代碼行數:13,代碼來源:unset_test.go

示例8: TestBlockSetConfig

func (s *configCommandSuite) TestBlockSetConfig(c *gc.C) {
	// Block operation
	s.fake.err = common.OperationBlockedError("TestBlockSetConfig")
	ctx := coretesting.ContextForDir(c, s.dir)
	code := cmd.Main(application.NewConfigCommandForTest(s.fake), ctx, []string{
		"dummy-application",
		"--file",
		"testconfig.yaml"})
	c.Check(code, gc.Equals, 1)
	// msg is logged
	stripped := strings.Replace(c.GetTestLog(), "\n", "", -1)
	c.Check(stripped, gc.Matches, ".*TestBlockSetConfig.*")
}
開發者ID:bac,項目名稱:juju,代碼行數:13,代碼來源:config_test.go

示例9: TestBlockSetConfig

func (s *SetSuite) TestBlockSetConfig(c *gc.C) {
	// Block operation
	s.fakeServiceAPI.err = common.OperationBlockedError("TestBlockSetConfig")
	ctx := coretesting.ContextForDir(c, s.dir)
	code := cmd.Main(service.NewSetCommandWithAPI(s.fakeClientAPI, s.fakeServiceAPI), ctx, []string{
		"dummy-service",
		"--config",
		"testconfig.yaml"})
	c.Check(code, gc.Equals, 1)
	// msg is logged
	stripped := strings.Replace(c.GetTestLog(), "\n", "", -1)
	c.Check(stripped, gc.Matches, ".*TestBlockSetConfig.*")
}
開發者ID:imoapps,項目名稱:juju,代碼行數:13,代碼來源:set_test.go

示例10: TestSetConfig

func (s *configCommandSuite) TestSetConfig(c *gc.C) {
	s.assertSetFail(c, s.dir, []string{
		"--file",
		"missing.yaml",
	}, "error.* "+utils.NoSuchFileErrRegexp+"\n")

	ctx := coretesting.ContextForDir(c, s.dir)
	code := cmd.Main(application.NewConfigCommandForTest(s.fake), ctx, []string{
		"dummy-application",
		"--file",
		"testconfig.yaml"})

	c.Check(code, gc.Equals, 0)
	c.Check(s.fake.config, gc.Equals, yamlConfigValue)
}
開發者ID:bac,項目名稱:juju,代碼行數:15,代碼來源:config_test.go

示例11: TestSetConfig

func (s *SetSuite) TestSetConfig(c *gc.C) {
	s.assertSetFail(c, s.dir, []string{
		"--config",
		"missing.yaml",
	}, "error.* "+utils.NoSuchFileErrRegexp+"\n")

	ctx := coretesting.ContextForDir(c, s.dir)
	code := cmd.Main(service.NewSetCommandWithAPI(s.fakeClientAPI, s.fakeServiceAPI), ctx, []string{
		"dummy-service",
		"--config",
		"testconfig.yaml"})

	c.Check(code, gc.Equals, 0)
	c.Check(s.fakeServiceAPI.config, gc.Equals, yamlConfigValue)
}
開發者ID:imoapps,項目名稱:juju,代碼行數:15,代碼來源:set_test.go

示例12: setupBigFile

// setupBigFile creates a too big file for testing
// set with [email protected]
func setupBigFile(c *gc.C, dir string) string {
	ctx := coretesting.ContextForDir(c, dir)
	path := ctx.AbsPath("big.txt")
	file, err := os.Create(path)
	c.Assert(err, gc.IsNil)
	defer file.Close()
	chunk := make([]byte, 1024)
	for i := 0; i < cap(chunk); i++ {
		chunk[i] = byte(i % 256)
	}
	for i := 0; i < 6000; i++ {
		_, err = file.Write(chunk)
		c.Assert(err, gc.IsNil)
	}
	return path
}
開發者ID:klyachin,項目名稱:juju,代碼行數:18,代碼來源:set_test.go

示例13: assertSetFail

// assertSetFail sets configuration options and checks the expected error.
func assertSetFail(c *gc.C, dir string, args []string, err string) {
	ctx := coretesting.ContextForDir(c, dir)
	code := cmd.Main(envcmd.Wrap(&SetCommand{}), ctx, append([]string{"dummy-service"}, args...))
	c.Check(code, gc.Not(gc.Equals), 0)
	c.Assert(ctx.Stderr.(*bytes.Buffer).String(), gc.Matches, err)
}
開發者ID:klyachin,項目名稱:juju,代碼行數:7,代碼來源:set_test.go

示例14: assertUnsetSuccess

// assertUnsetSuccess unsets configuration options and checks the expected settings.
func (s *UnsetSuite) assertUnsetSuccess(c *gc.C, dir string, args []string, expect map[string]interface{}) {
	ctx := coretesting.ContextForDir(c, dir)
	code := cmd.Main(envcmd.Wrap(service.NewUnsetCommand(s.fake)), ctx, append([]string{"dummy-service"}, args...))
	c.Check(code, gc.Equals, 0)
	c.Assert(s.fake.values, gc.DeepEquals, expect)
}
開發者ID:Pankov404,項目名稱:juju,代碼行數:7,代碼來源:unset_test.go

示例15: assertUnsetFail

// assertUnsetFail unsets configuration options and checks the expected error.
func (s *UnsetSuite) assertUnsetFail(c *gc.C, dir string, args []string, err string) {
	ctx := coretesting.ContextForDir(c, dir)
	code := cmd.Main(service.NewUnsetCommand(s.fake), ctx, append([]string{"dummy-service"}, args...))
	c.Check(code, gc.Not(gc.Equals), 0)
	c.Assert(ctx.Stderr.(*bytes.Buffer).String(), gc.Matches, err)
}
開發者ID:pmatulis,項目名稱:juju,代碼行數:7,代碼來源:unset_test.go


注:本文中的github.com/juju/juju/testing.ContextForDir函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。