本文整理汇总了Golang中github.com/juju/testing.JujuXDGDataHomePath函数的典型用法代码示例。如果您正苦于以下问题:Golang JujuXDGDataHomePath函数的具体用法?Golang JujuXDGDataHomePath怎么用?Golang JujuXDGDataHomePath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JujuXDGDataHomePath函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: TestSuccessNoJujuEnvironments
func (*jenvSuite) TestSuccessNoJujuEnvironments(c *gc.C) {
// Create a jenv file.
contents := makeValidJenvContents()
f := openJenvFile(c, contents)
defer f.Close()
// Remove the Juju environments.yaml file.
envPath := gitjujutesting.JujuXDGDataHomePath("environments.yaml")
err := os.Remove(envPath)
c.Assert(err, jc.ErrorIsNil)
// Importing a jenv does not require having environments already defined.
jenvCmd := &model.JenvCommand{}
ctx, err := testing.RunCommand(c, jenvCmd, f.Name())
c.Assert(err, jc.ErrorIsNil)
assertJenvContents(c, contents, "testing")
c.Assert(testing.Stdout(ctx), gc.Equals, "-> testing\n")
}
开发者ID:exekias,项目名称:juju,代码行数:18,代码来源:jenv_test.go
示例17: TestSwitchErrorEnvironmentsNotReadable
func (*jenvSuite) TestSwitchErrorEnvironmentsNotReadable(c *gc.C) {
if runtime.GOOS == "windows" {
c.Skip("Cannot test on windows because it uses chmod")
}
// Create a jenv file.
f := openJenvFile(c, makeValidJenvContents())
defer f.Close()
// Remove write permissions to the environments.yaml file.
envPath := gitjujutesting.JujuXDGDataHomePath("environments.yaml")
err := os.Chmod(envPath, 0200)
c.Assert(err, jc.ErrorIsNil)
jenvCmd := &model.JenvCommand{}
ctx, err := testing.RunCommand(c, jenvCmd, f.Name())
c.Assert(err, gc.ErrorMatches, `cannot switch to the new model "testing": cannot get the default model: .*: permission denied`)
c.Assert(testing.Stdout(ctx), gc.Equals, "")
}
开发者ID:exekias,项目名称:juju,代码行数:18,代码来源:jenv_test.go
示例18: TestWriteError
func (*jenvSuite) TestWriteError(c *gc.C) {
if runtime.GOOS == "windows" {
c.Skip("Cannot test on windows because it uses chmod")
}
// Create a jenv file.
f := openJenvFile(c, makeValidJenvContents())
defer f.Close()
// Create the environments dir without write permissions.
envsDir := gitjujutesting.JujuXDGDataHomePath("models")
err := os.Mkdir(envsDir, 0500)
c.Assert(err, jc.ErrorIsNil)
jenvCmd := &model.JenvCommand{}
ctx, err := testing.RunCommand(c, jenvCmd, f.Name())
c.Assert(err, gc.ErrorMatches, "cannot write the jenv file: cannot write info: .*: permission denied")
c.Assert(testing.Stdout(ctx), gc.Equals, "")
}
开发者ID:exekias,项目名称:juju,代码行数:18,代码来源:jenv_test.go
示例19: TestConfigStoreError
func (*jenvSuite) TestConfigStoreError(c *gc.C) {
if runtime.GOOS == "windows" {
c.Skip("Cannot test on windows because it uses chmod")
}
// Create a jenv file.
f := openJenvFile(c, nil)
defer f.Close()
// Remove Juju home read permissions.
home := gitjujutesting.JujuXDGDataHomePath()
err := os.Chmod(home, 0)
c.Assert(err, jc.ErrorIsNil)
defer os.Chmod(home, 0700)
jenvCmd := &model.JenvCommand{}
ctx, err := testing.RunCommand(c, jenvCmd, f.Name())
c.Assert(err, gc.ErrorMatches, "cannot get config store: .*: permission denied")
c.Assert(testing.Stdout(ctx), gc.Equals, "")
}
开发者ID:exekias,项目名称:juju,代码行数:19,代码来源:jenv_test.go
示例20: TestDefaultConfigFile
func (*suite) TestDefaultConfigFile(c *gc.C) {
env := `
environments:
only:
type: dummy
controller: false
authorized-keys: i-am-a-key
`
outfile, err := environs.WriteEnvirons("", env)
c.Assert(err, jc.ErrorIsNil)
path := gitjujutesting.JujuXDGDataHomePath("environments.yaml")
c.Assert(path, gc.Equals, outfile)
envs, err := environs.ReadEnvirons("")
c.Assert(err, jc.ErrorIsNil)
cfg, err := envs.Config("")
c.Assert(err, jc.ErrorIsNil)
c.Assert(cfg.Name(), gc.Equals, "only")
}
开发者ID:exekias,项目名称:juju,代码行数:19,代码来源:config_test.go
注:本文中的github.com/juju/testing.JujuXDGDataHomePath函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论