本文整理汇总了Golang中launchpad/net/juju-core/testing.MakeEmptyFakeHome函数的典型用法代码示例。如果您正苦于以下问题:Golang MakeEmptyFakeHome函数的具体用法?Golang MakeEmptyFakeHome怎么用?Golang MakeEmptyFakeHome使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MakeEmptyFakeHome函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestFakeHomeRestoresEnvironment
func (s *TestingEnvironSuite) TestFakeHomeRestoresEnvironment(c *C) {
fake := testing.MakeEmptyFakeHome(c)
fake.Restore()
c.Assert(os.Getenv("HOME"), Equals, "/home/eric")
c.Assert(os.Getenv("JUJU_HOME"), Equals, "/home/eric/juju")
c.Assert(config.JujuHome(), Equals, "/home/eric/juju")
}
示例2: TestConfigNoCertFiles
func (*ConfigSuite) TestConfigNoCertFiles(c *gc.C) {
h := testing.MakeEmptyFakeHome(c)
defer h.Restore()
for i, test := range noCertFilesTests {
c.Logf("test %d. %s", i, test.about)
test.check(c, h)
}
}
示例3: SetUpTest
func (s *ConfigSuite) SetUpTest(c *gc.C) {
s.oldJujuHome = testing.MakeEmptyFakeHome(c)
s.savedVars = make(map[string]string)
for v, val := range envVars {
s.savedVars[v] = os.Getenv(v)
os.Setenv(v, val)
}
}
示例4: TestImageMetadataBadArgs
func (s *ImageMetadataSuite) TestImageMetadataBadArgs(c *gc.C) {
defer testing.MakeEmptyFakeHome(c).Restore()
for i, t := range errTests {
c.Logf("test: %d", i)
ctx := testing.Context(c)
code := cmd.Main(&ImageMetadataCommand{}, ctx, t.args)
c.Check(code, gc.Equals, 2)
}
}
示例5: TestDebugLogInvokesSSHCommand
// debug-log is implemented by invoking juju ssh with the correct arguments.
// This test checks for the expected invocation.
func (s *DebugLogSuite) TestDebugLogInvokesSSHCommand(c *C) {
defer testing.MakeEmptyFakeHome(c).Restore()
debugLogCmd, err := runDebugLog(c)
c.Assert(err, IsNil)
debugCmd := debugLogCmd.sshCmd.(*dummySSHCommand)
c.Assert(debugCmd.runCalled, Equals, true)
c.Assert(debugCmd.Target, Equals, "0")
c.Assert([]string{"tail -f /var/log/juju/all-machines.log"}, DeepEquals, debugCmd.Args)
}
示例6: TestImageMetadataFilesDefaultArch
func (s *ImageMetadataSuite) TestImageMetadataFilesDefaultArch(c *gc.C) {
defer testing.MakeEmptyFakeHome(c).Restore()
ctx := testing.Context(c)
code := cmd.Main(
&ImageMetadataCommand{}, ctx, []string{"-i", "1234", "-r", "region", "-u", "endpoint", "-s", "raring"})
c.Assert(code, gc.Equals, 0)
errOut := ctx.Stdout.(*bytes.Buffer).String()
s.assertCommandOutput(c, errOut, "raring", "amd64", defaultIndexFileName, defaultImageFileName)
}
示例7: TestImageMetadataFilesUsingEnvEndpoint
func (s *ImageMetadataSuite) TestImageMetadataFilesUsingEnvEndpoint(c *gc.C) {
defer testing.MakeEmptyFakeHome(c).Restore()
os.Setenv("OS_AUTH_URL", "endpoint")
ctx := testing.Context(c)
code := cmd.Main(
&ImageMetadataCommand{}, ctx, []string{"-i", "1234", "-r", "region"})
c.Assert(code, gc.Equals, 0)
errOut := ctx.Stdout.(*bytes.Buffer).String()
s.assertCommandOutput(c, errOut, "precise", "amd64", defaultIndexFileName, defaultImageFileName)
}
示例8: TestBoilerPlatePrinted
// The boilerplate is sent to stdout with --show, and the environments.yaml
// is not created.
func (*InitSuite) TestBoilerPlatePrinted(c *C) {
defer testing.MakeEmptyFakeHome(c).Restore()
ctx := testing.Context(c)
code := cmd.Main(&InitCommand{}, ctx, []string{"--show"})
c.Check(code, Equals, 0)
outStr := ctx.Stdout.(*bytes.Buffer).String()
strippedOut := strings.Replace(outStr, "\n", "", -1)
c.Check(strippedOut, Matches, ".*## This is the Juju config file, which you can use.*")
environpath := testing.HomePath(".juju", "environments.yaml")
_, err := ioutil.ReadFile(environpath)
c.Assert(err, NotNil)
}
示例9: TestBoilerPlateEnvironment
// The environments.yaml is created by default if it
// does not already exist.
func (*InitSuite) TestBoilerPlateEnvironment(c *C) {
defer testing.MakeEmptyFakeHome(c).Restore()
ctx := testing.Context(c)
code := cmd.Main(&InitCommand{}, ctx, nil)
c.Check(code, Equals, 0)
outStr := ctx.Stdout.(*bytes.Buffer).String()
strippedOut := strings.Replace(outStr, "\n", "", -1)
c.Check(strippedOut, Matches, ".*A boilerplate environment configuration file has been written.*")
environpath := testing.HomePath(".juju", "environments.yaml")
data, err := ioutil.ReadFile(environpath)
c.Assert(err, IsNil)
strippedData := strings.Replace(string(data), "\n", "", -1)
c.Assert(strippedData, Matches, ".*## This is the Juju config file, which you can use.*")
}
示例10: TestDefaultConfigFile
func (suite) TestDefaultConfigFile(c *C) {
defer testing.MakeEmptyFakeHome(c).Restore()
env := `
environments:
only:
type: dummy
state-server: false
authorized-keys: i-am-a-key
`
outfile, err := environs.WriteEnvirons("", env)
c.Assert(err, IsNil)
path := testing.HomePath(".juju", "environments.yaml")
c.Assert(path, Equals, outfile)
es, err := environs.ReadEnvirons("")
c.Assert(err, IsNil)
e, err := es.Open("")
c.Assert(err, IsNil)
c.Assert(e.Name(), Equals, "only")
}
示例11: TestWriteCertAndKey
func (*EnvironsCertSuite) TestWriteCertAndKey(c *C) {
defer testing.MakeEmptyFakeHome(c).Restore()
// Ensure that the juju home path is different
// from $HOME/.juju to check that WriteCertAndKey
// isn't just using $HOME.
config.SetJujuHome(c.MkDir())
cert, key := []byte("a cert"), []byte("a key")
err := environs.WriteCertAndKey("foo", cert, key)
c.Assert(err, IsNil)
// Check that the generated CA key has been written correctly.
caCertPEM, err := ioutil.ReadFile(config.JujuHomePath("foo-cert.pem"))
c.Assert(err, IsNil)
c.Assert(caCertPEM, DeepEquals, cert)
caKeyPEM, err := ioutil.ReadFile(config.JujuHomePath("foo-private-key.pem"))
c.Assert(err, IsNil)
c.Assert(caKeyPEM, DeepEquals, key)
}
示例12: TestNoEnvironment
func (*SwitchSimpleSuite) TestNoEnvironment(c *C) {
defer testing.MakeEmptyFakeHome(c).Restore()
_, err := testing.RunCommand(c, &SwitchCommand{}, nil)
c.Assert(err, ErrorMatches, "couldn't read the environment.")
}
示例13: TestFakeHomeSetsConfigJujuHome
func (s *TestingEnvironSuite) TestFakeHomeSetsConfigJujuHome(c *C) {
_ = testing.MakeEmptyFakeHome(c)
expected := filepath.Join(os.Getenv("HOME"), ".juju")
c.Assert(config.JujuHome(), Equals, expected)
}
示例14: TestFakeHomeReplacesEnvironment
func (s *TestingEnvironSuite) TestFakeHomeReplacesEnvironment(c *C) {
_ = testing.MakeEmptyFakeHome(c)
c.Assert(os.Getenv("HOME"), Not(Equals), "/home/eric")
c.Assert(os.Getenv("JUJU_HOME"), Equals, "")
c.Assert(config.JujuHome(), Not(Equals), "/home/eric/juju")
}
示例15: SetUpTest
func (s *ValidateSuite) SetUpTest(c *gc.C) {
s.home = coretesting.MakeEmptyFakeHome(c)
}