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


Golang testing.JujuXDGDataHomePath函數代碼示例

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


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

示例1: TestBoilerPlatePrinted

// The boilerplate is sent to stdout with --show, and the environments.yaml
// is not created.
func (*InitSuite) TestBoilerPlatePrinted(c *gc.C) {
	envPath := gitjujutesting.JujuXDGDataHomePath("environments.yaml")
	err := os.Remove(envPath)
	c.Assert(err, jc.ErrorIsNil)
	ctx := testing.Context(c)
	code := cmd.Main(&initCommand{}, ctx, []string{"--show"})
	c.Check(code, gc.Equals, 0)
	outStr := ctx.Stdout.(*bytes.Buffer).String()
	strippedOut := strings.Replace(outStr, "\n", "", -1)
	c.Check(strippedOut, gc.Matches, ".*# This is the Juju config file, which you can use.*")
	environpath := gitjujutesting.JujuXDGDataHomePath("environments.yaml")
	_, err = ioutil.ReadFile(environpath)
	c.Assert(err, gc.NotNil)
}
開發者ID:exekias,項目名稱:juju,代碼行數:16,代碼來源:init_test.go

示例2: TestConfigPerm

func (s *suite) TestConfigPerm(c *gc.C) {
	testing.MakeSampleJujuHome(c)

	path := gitjujutesting.JujuXDGDataHomePath()
	info, err := os.Lstat(path)
	c.Assert(err, jc.ErrorIsNil)
	oldPerm := info.Mode().Perm()
	env := `
environments:
    only:
        type: dummy
        controller: false
        authorized-keys: i-am-a-key
`
	outfile, err := environs.WriteEnvirons("", env)
	c.Assert(err, jc.ErrorIsNil)

	info, err = os.Lstat(outfile)
	c.Assert(err, jc.ErrorIsNil)
	// Windows is not fully POSIX compliant. Normal permission
	// checking will yield unexpected results
	if runtime.GOOS != "windows" {
		c.Assert(info.Mode().Perm(), gc.Equals, os.FileMode(0600))
	}

	info, err = os.Lstat(filepath.Dir(outfile))
	c.Assert(err, jc.ErrorIsNil)
	if runtime.GOOS != "windows" {
		c.Assert(info.Mode().Perm(), gc.Equals, oldPerm)
	}

}
開發者ID:exekias,項目名稱:juju,代碼行數:32,代碼來源:config_test.go

示例3: TestNoDefaultNoEnvironmentsFile

func (*SwitchSimpleSuite) TestNoDefaultNoEnvironmentsFile(c *gc.C) {
	envPath := gitjujutesting.JujuXDGDataHomePath("environments.yaml")
	err := os.Remove(envPath)
	c.Assert(err, jc.ErrorIsNil)
	_, err = testing.RunCommand(c, newSwitchCommand())
	c.Assert(err, gc.ErrorMatches, "no currently specified model")
}
開發者ID:exekias,項目名稱:juju,代碼行數:7,代碼來源:switch_test.go

示例4: TestBoilerPlateEnvironment

// The environments.yaml is created by default if it
// does not already exist.
func (*InitSuite) TestBoilerPlateEnvironment(c *gc.C) {
	envPath := gitjujutesting.JujuXDGDataHomePath("environments.yaml")
	err := os.Remove(envPath)
	c.Assert(err, jc.ErrorIsNil)
	ctx := testing.Context(c)
	code := cmd.Main(&initCommand{}, ctx, nil)
	c.Check(code, gc.Equals, 0)
	outStr := ctx.Stdout.(*bytes.Buffer).String()
	strippedOut := strings.Replace(outStr, "\n", "", -1)
	c.Check(strippedOut, gc.Matches, ".*A boilerplate model configuration file has been written.*")
	environpath := gitjujutesting.JujuXDGDataHomePath("environments.yaml")
	data, err := ioutil.ReadFile(environpath)
	c.Assert(err, jc.ErrorIsNil)
	strippedData := strings.Replace(string(data), "\n", "", -1)
	c.Assert(strippedData, gc.Matches, ".*# This is the Juju config file, which you can use.*")
}
開發者ID:exekias,項目名稱:juju,代碼行數:18,代碼來源:init_test.go

示例5: SetUpTest

func (s *jenvSuite) SetUpTest(c *gc.C) {
	s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
	dir := gitjujutesting.JujuXDGDataHomePath()
	err := os.MkdirAll(dir, 0600)
	c.Check(err, jc.ErrorIsNil)

}
開發者ID:exekias,項目名稱:juju,代碼行數:7,代碼來源:jenv_test.go

示例6: SetUpTest

func (s *FakeJujuXDGDataHomeSuite) SetUpTest(c *gc.C) {
	s.JujuOSEnvSuite.SetUpTest(c)
	s.FakeHomeSuite.SetUpTest(c)
	jujuXDGDataHome := gitjujutesting.JujuXDGDataHomePath()
	err := os.MkdirAll(jujuXDGDataHome, 0700)
	c.Assert(err, jc.ErrorIsNil)
	s.oldJujuXDGDataHome = osenv.SetJujuXDGDataHome(jujuXDGDataHome)
}
開發者ID:AlexisBruemmer,項目名稱:juju,代碼行數:8,代碼來源:environ.go

示例7: TestGetDefaultModelNothingSet

func (s *ModelCommandSuite) TestGetDefaultModelNothingSet(c *gc.C) {
	envPath := gitjujutesting.JujuXDGDataHomePath("environments.yaml")
	err := os.Remove(envPath)
	c.Assert(err, jc.ErrorIsNil)
	env, err := modelcmd.GetDefaultModel()
	c.Assert(env, gc.Equals, "")
	c.Assert(err, jc.ErrorIsNil)
}
開發者ID:exekias,項目名稱:juju,代碼行數:8,代碼來源:modelcommand_test.go

示例8: TestNoEnv

func (*suite) TestNoEnv(c *gc.C) {
	envPath := gitjujutesting.JujuXDGDataHomePath("environments.yaml")
	err := os.Remove(envPath)
	c.Assert(err, jc.ErrorIsNil)
	es, err := environs.ReadEnvirons("")
	c.Assert(es, gc.IsNil)
	c.Assert(err, jc.Satisfies, environs.IsNoEnv)
}
開發者ID:exekias,項目名稱:juju,代碼行數:8,代碼來源:config_test.go

示例9: TestControllerCommandInitNoEnvFile

func (s *ControllerCommandSuite) TestControllerCommandInitNoEnvFile(c *gc.C) {
	// Since we ignore the environments.yaml file, we don't care if it isn't
	// there.
	envPath := gitjujutesting.JujuXDGDataHomePath("environments.yaml")
	err := os.Remove(envPath)
	_, err = initTestControllerCommand(c)
	c.Assert(err, gc.ErrorMatches, "no controller specified")
}
開發者ID:exekias,項目名稱:juju,代碼行數:8,代碼來源:controller_test.go

示例10: SetUpTest

func (s *FakeJujuXDGDataHomeSuite) SetUpTest(c *gc.C) {
	s.JujuOSEnvSuite.SetUpTest(c)
	s.FakeHomeSuite.SetUpTest(c)
	jujuXDGDataHome := gitjujutesting.JujuXDGDataHomePath()
	err := os.MkdirAll(jujuXDGDataHome, 0700)
	c.Assert(err, jc.ErrorIsNil)
	s.oldJujuXDGDataHome = osenv.SetJujuXDGDataHome(jujuXDGDataHome)
	WriteEnvironments(c, SingleEnvConfig, SampleCertName)
}
開發者ID:exekias,項目名稱:juju,代碼行數:9,代碼來源:environ.go

示例11: TestNoEnvironmentReadsConfigStore

func (s *SwitchSimpleSuite) TestNoEnvironmentReadsConfigStore(c *gc.C) {
	envPath := gitjujutesting.JujuXDGDataHomePath("environments.yaml")
	err := os.Remove(envPath)
	c.Assert(err, jc.ErrorIsNil)
	s.addTestController(c)
	context, err := testing.RunCommand(c, newSwitchCommand(), "--list")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(testing.Stdout(context), gc.Equals, "a-controller (controller)\n")
}
開發者ID:exekias,項目名稱:juju,代碼行數:9,代碼來源:switch_test.go

示例12: TestErrorReadingEnvironmentsFile

func (s *SwitchSimpleSuite) TestErrorReadingEnvironmentsFile(c *gc.C) {
	if runtime.GOOS == "windows" {
		c.Skip("bug 1496997: os.Chmod doesn't exist on windows, checking this on one platform is sufficent to test this case")
	}

	envPath := gitjujutesting.JujuXDGDataHomePath("environments.yaml")
	err := os.Chmod(envPath, 0)
	c.Assert(err, jc.ErrorIsNil)
	s.addTestController(c)
	_, err = testing.RunCommand(c, newSwitchCommand(), "--list")
	c.Assert(err, gc.ErrorMatches, "couldn't read the model: open .*: permission denied")
}
開發者ID:exekias,項目名稱:juju,代碼行數:12,代碼來源:switch_test.go

示例13: resetJujuXDGDataHome

// resetJujuXDGDataHome restores an new, clean Juju home environment without tools.
func resetJujuXDGDataHome(c *gc.C, envName string) environs.Environ {
	jenvDir := testing.JujuXDGDataHomePath("models")
	err := os.RemoveAll(jenvDir)
	c.Assert(err, jc.ErrorIsNil)
	coretesting.WriteEnvironments(c, modelConfig)
	dummy.Reset()
	store, err := configstore.Default()
	c.Assert(err, jc.ErrorIsNil)
	env, err := environs.PrepareFromName(envName, modelcmd.BootstrapContext(cmdtesting.NullContext(c)), store)
	c.Assert(err, jc.ErrorIsNil)
	return env
}
開發者ID:OSBI,項目名稱:juju,代碼行數:13,代碼來源:bootstrap_test.go

示例14: TestExistingEnvironmentNotOverwritten

// An existing environments.yaml will not be overwritten without
// the explicit -f option.
func (*InitSuite) TestExistingEnvironmentNotOverwritten(c *gc.C) {
	testing.WriteEnvironments(c, existingEnv)

	ctx := testing.Context(c)
	code := cmd.Main(&initCommand{}, ctx, nil)
	c.Check(code, gc.Equals, 1)
	errOut := ctx.Stderr.(*bytes.Buffer).String()
	strippedOut := strings.Replace(errOut, "\n", "", -1)
	c.Check(strippedOut, gc.Matches, ".*A juju model configuration already exists.*")
	environpath := gitjujutesting.JujuXDGDataHomePath("environments.yaml")
	data, err := ioutil.ReadFile(environpath)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(string(data), gc.Equals, existingEnv)
}
開發者ID:exekias,項目名稱:juju,代碼行數:16,代碼來源:init_test.go

示例15: assertJenvContents

// assertJenvContents checks that the jenv file corresponding to the given
// envName is correctly present in the Juju Home and has the given contents.
func assertJenvContents(c *gc.C, contents []byte, envName string) {
	path := gitjujutesting.JujuXDGDataHomePath("models", envName+".jenv")
	// Ensure the jenv file has been created.
	c.Assert(path, jc.IsNonEmptyFile)

	// Retrieve the jenv file contents.
	b, err := ioutil.ReadFile(path)
	c.Assert(err, jc.ErrorIsNil)

	// Ensure the jenv file reflects the source contents.
	var data map[string]interface{}
	err = yaml.Unmarshal(contents, &data)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(string(b), jc.YAMLEquals, data)
}
開發者ID:exekias,項目名稱:juju,代碼行數:17,代碼來源:jenv_test.go


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