예제 #1
0
func (s *flagWinSuite) TestParsing(c *gc.C) {
	s.k.SetStringValue("JUJU_TESTING_FEATURE", "MAGIC, test, space ")
	featureflag.SetFlagsFromRegistry(regKey, "JUJU_TESTING_FEATURE")
	c.Assert(featureflag.All(), jc.SameContents, []string{"magic", "space", "test"})
	c.Assert(featureflag.AsEnvironmentValue(), gc.Equals, "magic,space,test")
	c.Assert(featureflag.String(), gc.Equals, `"magic", "space", "test"`)
}
예제 #2
0
func (s *flagWinSuite) TestEmpty(c *gc.C) {
	s.k.SetStringValue("JUJU_TESTING_FEATURE", "")
	featureflag.SetFlagsFromRegistry(regKey, "JUJU_TESTING_FEATURE")
	c.Assert(featureflag.All(), gc.HasLen, 0)
	c.Assert(featureflag.AsEnvironmentValue(), gc.Equals, "")
	c.Assert(featureflag.String(), gc.Equals, "")
}
예제 #3
0
파일: main_windows.go 프로젝트: bac/juju
func init() {
	if FLAGSFROMENVIRONMENT == "true" {
		featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey)
	} else {
		featureflag.SetFlagsFromRegistry(osenv.JujuRegistryKey, osenv.JujuFeatureFlagEnvKey)
	}
}
예제 #4
0
func (s *flagWinSuite) TestEnabled(c *gc.C) {
	c.Assert(featureflag.Enabled(""), jc.IsTrue)
	c.Assert(featureflag.Enabled(" "), jc.IsTrue)
	c.Assert(featureflag.Enabled("magic"), jc.IsFalse)

	s.k.SetStringValue("JUJU_TESTING_FEATURE", "MAGIC")
	featureflag.SetFlagsFromRegistry(regKey, "JUJU_TESTING_FEATURE")

	c.Assert(featureflag.Enabled("magic"), jc.IsTrue)
	c.Assert(featureflag.Enabled("Magic"), jc.IsTrue)
	c.Assert(featureflag.Enabled(" MAGIC "), jc.IsTrue)
}
예제 #5
0
// setUpFeatureFlags sets the feature flags from the environment, but
// also sets up the registry key on windows because some functions are
// trying to look in there.
func (s *JujuOSEnvSuite) setUpFeatureFlags(c *gc.C) {
	regKey := osenv.JujuRegistryKey[len(`HKLM:\`):]
	k, existed, err := registry.CreateKey(registry.LOCAL_MACHINE, regKey, registry.ALL_ACCESS)
	s.regKeyExisted = existed
	c.Assert(err, jc.ErrorIsNil)
	val, _, err := k.GetStringValue(osenv.JujuFeatureFlagEnvKey)
	if errors.Cause(err) == registry.ErrNotExist {
		s.regEntryExisted = false
	} else {
		c.Assert(err, jc.ErrorIsNil)
		s.oldRegEntryValue = val
		s.regEntryExisted = true
	}
	err = k.SetStringValue(osenv.JujuFeatureFlagEnvKey, s.initialFeatureFlags)
	c.Assert(err, jc.ErrorIsNil)
	featureflag.SetFlagsFromRegistry(osenv.JujuRegistryKey, osenv.JujuFeatureFlagEnvKey)
	err = k.Close()
	c.Assert(err, jc.ErrorIsNil)

}
예제 #6
0
func init() {
	featureflag.SetFlagsFromRegistry(osenv.JujuRegistryKey, osenv.JujuFeatureFlagEnvKey)
}