当前位置: 首页>>代码示例>>Golang>>正文


Golang testing.MakeEmptyFakeHome函数代码示例

本文整理汇总了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")
}
开发者ID:rif,项目名称:golang-stuff,代码行数:7,代码来源:environ_test.go

示例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)
	}
}
开发者ID:rif,项目名称:golang-stuff,代码行数:8,代码来源:config_test.go

示例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)
	}
}
开发者ID:rif,项目名称:golang-stuff,代码行数:8,代码来源:config_test.go

示例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)
	}
}
开发者ID:hivetech,项目名称:judo.legacy,代码行数:9,代码来源:imagemetadata_test.go

示例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)
}
开发者ID:rif,项目名称:golang-stuff,代码行数:11,代码来源:debuglog_test.go

示例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)
}
开发者ID:hivetech,项目名称:judo.legacy,代码行数:10,代码来源:imagemetadata_test.go

示例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)
}
开发者ID:hivetech,项目名称:judo.legacy,代码行数:11,代码来源:imagemetadata_test.go

示例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)
}
开发者ID:hivetech,项目名称:judo.legacy,代码行数:14,代码来源:init_test.go

示例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.*")
}
开发者ID:hivetech,项目名称:judo.legacy,代码行数:16,代码来源:init_test.go

示例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")
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:21,代码来源:config_test.go

示例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)

}
开发者ID:rif,项目名称:golang-stuff,代码行数:22,代码来源:cert_test.go

示例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.")
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:5,代码来源:switch_test.go

示例13: TestFakeHomeSetsConfigJujuHome

func (s *TestingEnvironSuite) TestFakeHomeSetsConfigJujuHome(c *C) {
	_ = testing.MakeEmptyFakeHome(c)
	expected := filepath.Join(os.Getenv("HOME"), ".juju")
	c.Assert(config.JujuHome(), Equals, expected)
}
开发者ID:rif,项目名称:golang-stuff,代码行数:5,代码来源:environ_test.go

示例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")
}
开发者ID:rif,项目名称:golang-stuff,代码行数:6,代码来源:environ_test.go

示例15: SetUpTest

func (s *ValidateSuite) SetUpTest(c *gc.C) {
	s.home = coretesting.MakeEmptyFakeHome(c)
}
开发者ID:hivetech,项目名称:judo.legacy,代码行数:3,代码来源:validation_test.go


注:本文中的launchpad/net/juju-core/testing.MakeEmptyFakeHome函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。