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


Golang osenv.SetJujuXDGDataHome函数代码示例

本文整理汇总了Golang中github.com/juju/juju/juju/osenv.SetJujuXDGDataHome函数的典型用法代码示例。如果您正苦于以下问题:Golang SetJujuXDGDataHome函数的具体用法?Golang SetJujuXDGDataHome怎么用?Golang SetJujuXDGDataHome使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SetJujuXDGDataHome函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestHelpCommands

func (s *MainSuite) TestHelpCommands(c *gc.C) {
	defer osenv.SetJujuXDGDataHome(osenv.SetJujuXDGDataHome(c.MkDir()))

	// Check that we have correctly registered all the commands
	// by checking the help output.
	// First check default commands, and then check commands that are
	// activated by feature flags.

	// remove features behind dev_flag for the first test
	// since they are not enabled.
	cmdSet := set.NewStrings(commandNames...)

	// 1. Default Commands. Disable all features.
	setFeatureFlags("")
	// Use sorted values here so we can better see what is wrong.
	registered := getHelpCommandNames(c)
	unknown := registered.Difference(cmdSet)
	c.Assert(unknown, jc.DeepEquals, set.NewStrings())
	missing := cmdSet.Difference(registered)
	c.Assert(missing, jc.DeepEquals, set.NewStrings())

	// 2. Enable development features, and test again.
	cmdSet = cmdSet.Union(commandNamesBehindFlags)
	setFeatureFlags(strings.Join(devFeatures, ","))
	registered = getHelpCommandNames(c)
	unknown = registered.Difference(cmdSet)
	c.Assert(unknown, jc.DeepEquals, set.NewStrings())
	missing = cmdSet.Difference(registered)
	c.Assert(missing, jc.DeepEquals, set.NewStrings())
}
开发者ID:makyo,项目名称:juju,代码行数:30,代码来源:main_test.go

示例2: TestBoilerPlateAliases

func (*BoilerplateConfigSuite) TestBoilerPlateAliases(c *gc.C) {
	defer osenv.SetJujuXDGDataHome(osenv.SetJujuXDGDataHome(c.MkDir()))
	boilerplate_text := environs.BoilerplateConfig()
	// There should be only one occurrence of "manual", despite
	// there being an alias ("null"). There should be nothing for
	// aliases.
	n := strings.Count(boilerplate_text, "type: manual")
	c.Assert(n, gc.Equals, 1)
	n = strings.Count(boilerplate_text, "type: null")
	c.Assert(n, gc.Equals, 0)
}
开发者ID:exekias,项目名称:juju,代码行数:11,代码来源:boilerplate_config_test.go

示例3: SetUpTest

func (s *JujuOSEnvSuite) SetUpTest(c *gc.C) {
	s.oldEnvironment = make(map[string]string)
	for _, name := range []string{
		osenv.JujuXDGDataHomeEnvKey,
		osenv.JujuModelEnvKey,
		osenv.JujuLoggingConfigEnvKey,
		osenv.JujuFeatureFlagEnvKey,
		osenv.XDGDataHome,
	} {
		s.oldEnvironment[name] = os.Getenv(name)
		os.Setenv(name, "")
	}
	s.oldHomeEnv = utils.Home()
	s.oldJujuXDGDataHome = osenv.SetJujuXDGDataHome("")
	utils.SetHome("")

	// Update the feature flag set to be the requested initial set.
	// This works for both windows and unix, even though normally
	// the feature flags on windows are determined using the registry.
	// For tests, setting with the environment variable isolates us
	// from a single resource that was hitting contention during parallel
	// test runs.
	os.Setenv(osenv.JujuFeatureFlagEnvKey, s.initialFeatureFlags)
	featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:25,代码来源:base.go

示例4: TearDownTest

func (s *JujuOSEnvSuite) TearDownTest(c *gc.C) {
	for name, value := range s.oldEnvironment {
		os.Setenv(name, value)
	}
	utils.SetHome(s.oldHomeEnv)
	osenv.SetJujuXDGDataHome(s.oldJujuXDGDataHome)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:base.go

示例5: SetUpTest

func (s *TestingBaseSuite) SetUpTest(c *gc.C) {
	utils.SetHome(home)
	os.Setenv("JUJU_DATA", jujuXDGDataHome)
	osenv.SetJujuXDGDataHome(jujuXDGDataHome)

	s.BaseSuite.SetUpTest(c)
}
开发者ID:exekias,项目名称:juju,代码行数:7,代码来源:base_test.go

示例6: CreateUserHome

// Create a home directory and Juju data home for user username.
// This is used by setUpConn to create the 'ubuntu' user home, after RootDir,
// and may be used again later for other users.
func (s *JujuConnSuite) CreateUserHome(c *gc.C, params *UserHomeParams) {
	if s.RootDir == "" {
		c.Fatal("JujuConnSuite.setUpConn required first for RootDir")
	}
	c.Assert(params.Username, gc.Not(gc.Equals), "")
	home := filepath.Join(s.RootDir, "home", params.Username)
	err := os.MkdirAll(home, 0777)
	c.Assert(err, jc.ErrorIsNil)
	err = utils.SetHome(home)
	c.Assert(err, jc.ErrorIsNil)

	jujuHome := filepath.Join(home, ".local", "share")
	err = os.MkdirAll(filepath.Join(home, ".local", "share"), 0777)
	c.Assert(err, jc.ErrorIsNil)

	previousJujuXDGDataHome := osenv.SetJujuXDGDataHome(jujuHome)
	if params.SetOldHome {
		s.oldJujuXDGDataHome = previousJujuXDGDataHome
	}

	err = os.MkdirAll(s.DataDir(), 0777)
	c.Assert(err, jc.ErrorIsNil)

	jujuModelEnvKey := "JUJU_MODEL"
	if params.ModelEnvKey != "" {
		jujuModelEnvKey = params.ModelEnvKey
	}
	s.PatchEnvironment(osenv.JujuModelEnvKey, jujuModelEnvKey)

	s.ControllerStore = jujuclient.NewFileClientStore()
}
开发者ID:bac,项目名称:juju,代码行数:34,代码来源:conn.go

示例7: SetUpTest

func (s *fakeHomeSuite) SetUpTest(c *gc.C) {
	utils.SetHome(home)
	os.Setenv("JUJU_DATA", jujuXDGDataHome)
	osenv.SetJujuXDGDataHome(jujuXDGDataHome)

	s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
}
开发者ID:exekias,项目名称:juju,代码行数:7,代码来源:environ_test.go

示例8: TearDownTest

func (s *JujuOSEnvSuite) TearDownTest(c *gc.C) {
	for name, value := range s.oldEnvironment {
		os.Setenv(name, value)
	}
	err := utils.SetHome(s.oldHomeEnv)
	c.Assert(err, jc.ErrorIsNil)
	osenv.SetJujuXDGDataHome(s.oldJujuXDGDataHome)
}
开发者ID:xushiwei,项目名称:juju,代码行数:8,代码来源:base.go

示例9: TestHelpTopics

func (s *MainSuite) TestHelpTopics(c *gc.C) {
	// Check that we have correctly registered all the topics
	// by checking the help output.
	defer osenv.SetJujuXDGDataHome(osenv.SetJujuXDGDataHome(c.MkDir()))
	out := badrun(c, 0, "help", "topics")
	lines := strings.Split(out, "\n")
	var names []string
	for _, line := range lines {
		f := strings.Fields(line)
		if len(f) == 0 {
			continue
		}
		names = append(names, f[0])
	}
	// The names should be output in alphabetical order, so don't sort.
	c.Assert(names, gc.DeepEquals, topicNames)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:17,代码来源:main_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)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:8,代码来源:environ.go

示例11: TestWritePublicCloudsMetadata

func (s *cloudSuite) TestWritePublicCloudsMetadata(c *gc.C) {
	origHome := osenv.SetJujuXDGDataHome(c.MkDir())
	s.AddCleanup(func(*gc.C) { osenv.SetJujuXDGDataHome(origHome) })

	clouds := map[string]cloud.Cloud{
		"aws-me": cloud.Cloud{
			Type:      "aws",
			AuthTypes: []cloud.AuthType{"userpass"},
		},
	}
	err := cloud.WritePublicCloudMetadata(clouds)
	c.Assert(err, jc.ErrorIsNil)
	publicClouds, fallbackUsed, err := cloud.PublicCloudMetadata(cloud.JujuPublicCloudsPath())
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(fallbackUsed, jc.IsFalse)
	c.Assert(publicClouds, jc.DeepEquals, clouds)
}
开发者ID:makyo,项目名称:juju,代码行数:17,代码来源:clouds_test.go

示例12: SetUpTest

func (s *fakeHomeSuite) SetUpTest(c *gc.C) {
	err := utils.SetHome(home)
	c.Assert(err, jc.ErrorIsNil)
	os.Setenv("JUJU_DATA", jujuXDGDataHome)
	osenv.SetJujuXDGDataHome(jujuXDGDataHome)

	s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
}
开发者ID:xushiwei,项目名称:juju,代码行数:8,代码来源:environ_test.go

示例13: 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

示例14: SetUpTest

func (s *BaseSuite) SetUpTest(c *gc.C) {
	s.IsolationSuite.SetUpTest(c)

	s.PatchValue(&newConnection, newFakeConnection)
	s.initEnv(c)
	s.setUpHttpProxy(c)
	s.FakeMetadataServer()
	osenv.SetJujuXDGDataHome(c.MkDir())
}
开发者ID:exekias,项目名称:juju,代码行数:9,代码来源:testing_test.go

示例15: TestUpdateCredentialRemovesDefaultIfNecessary

func (s *CredentialsSuite) TestUpdateCredentialRemovesDefaultIfNecessary(c *gc.C) {
	origHome := osenv.SetJujuXDGDataHome(c.MkDir())
	s.AddCleanup(func(*gc.C) { osenv.SetJujuXDGDataHome(origHome) })

	s.cloudName = firstTestCloudName(c)

	store := jujuclient.NewFileCredentialStore()
	err := store.UpdateCredential(s.cloudName, s.credentials)
	c.Assert(err, jc.ErrorIsNil)
	newCreds := s.credentials
	// "peter" is the default credential
	delete(newCreds.AuthCredentials, "peter")
	err = store.UpdateCredential(s.cloudName, newCreds)
	c.Assert(err, jc.ErrorIsNil)
	creds, err := store.AllCredentials()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(creds[s.cloudName].DefaultCredential, gc.Equals, "")
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:18,代码来源:credentials_test.go


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