當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。