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