當前位置: 首頁>>代碼示例>>Golang>>正文


Golang environs.ReadEnvironsBytes函數代碼示例

本文整理匯總了Golang中github.com/juju/juju/environs.ReadEnvironsBytes函數的典型用法代碼示例。如果您正苦於以下問題:Golang ReadEnvironsBytes函數的具體用法?Golang ReadEnvironsBytes怎麽用?Golang ReadEnvironsBytes使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ReadEnvironsBytes函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestInvalidConfig

func (*suite) TestInvalidConfig(c *gc.C) {
	for i, t := range invalidConfigTests {
		c.Logf("running test %v", i)
		_, err := environs.ReadEnvironsBytes([]byte(t.env))
		c.Check(err, gc.ErrorMatches, t.err)
	}
}
開發者ID:imoapps,項目名稱:juju,代碼行數:7,代碼來源:config_test.go

示例2: TestConfig

func (*suite) TestConfig(c *gc.C) {
	for i, t := range configTests {
		c.Logf("running test %v", i)
		envs, err := environs.ReadEnvironsBytes([]byte(t.env))
		c.Assert(err, jc.ErrorIsNil)
		t.check(c, envs)
	}
}
開發者ID:imoapps,項目名稱:juju,代碼行數:8,代碼來源:config_test.go

示例3: TestInvalidEnv

func (*suite) TestInvalidEnv(c *gc.C) {
	for i, t := range invalidEnvTests {
		c.Logf("running test %v", i)
		es, err := environs.ReadEnvironsBytes([]byte(t.env))
		c.Check(err, jc.ErrorIsNil)
		cfg, err := es.Config(t.name)
		c.Check(err, gc.ErrorMatches, t.err)
		c.Check(cfg, gc.IsNil)
	}
}
開發者ID:imoapps,項目名稱:juju,代碼行數:10,代碼來源:config_test.go

示例4: TestNoHomeBeforeConfig

func (*suite) TestNoHomeBeforeConfig(c *gc.C) {
	// Test that we don't actually need HOME set until we call envs.Config()
	os.Setenv("HOME", "")
	content := `
environments:
    valid:
        type: dummy
    amazon:
        type: ec2
`
	_, err := environs.ReadEnvironsBytes([]byte(content))
	c.Check(err, jc.ErrorIsNil)
}
開發者ID:imoapps,項目名稱:juju,代碼行數:13,代碼來源:config_test.go

示例5: TestDisallowedInBootstrap

func (s *suite) TestDisallowedInBootstrap(c *gc.C) {
	content := `
environments:
    dummy:
        type: dummy
        state-server: false
`
	for key, value := range map[string]interface{}{
		"storage-default-block-source": "loop",
	} {
		envContent := fmt.Sprintf("%s\n        %s: %s", content, key, value)
		envs, err := environs.ReadEnvironsBytes([]byte(envContent))
		c.Check(err, jc.ErrorIsNil)
		_, err = envs.Config("dummy")
		c.Assert(err, gc.ErrorMatches, "attribute .* is not allowed in bootstrap configurations")
	}
}
開發者ID:imoapps,項目名稱:juju,代碼行數:17,代碼來源:config_test.go

示例6: checkDeprecationWarning

func (s *ConfigDeprecationSuite) checkDeprecationWarning(c *gc.C, attrs testing.Attrs, expectedMsg string) {
	content := `
environments:
    deprecated:
        type: dummy
        state-server: false
`
	restore := s.setupLogger(c)
	defer restore()

	envs, err := environs.ReadEnvironsBytes([]byte(content))
	c.Check(err, gc.IsNil)
	environs.UpdateEnvironAttrs(envs, "deprecated", attrs)
	_, err = envs.Config("deprecated")
	c.Check(err, gc.IsNil)
	c.Assert(s.writer.Log, gc.HasLen, 1)
	stripped := strings.Replace(s.writer.Log[0].Message, "\n", "", -1)
	c.Assert(stripped, gc.Matches, expectedMsg)
}
開發者ID:rogpeppe,項目名稱:juju,代碼行數:19,代碼來源:config_test.go

示例7: TestNoWarningForDeprecatedButUnusedEnv

func (*suite) TestNoWarningForDeprecatedButUnusedEnv(c *gc.C) {
	// This tests that a config that has a deprecated field doesn't
	// generate a Warning if we don't actually ask for that environment.
	// However, we can only really trigger that when we have a deprecated
	// field. If support for the field is removed entirely, another
	// mechanism will need to be used
	content := `
environments:
    valid:
        type: dummy
        state-server: false
    deprecated:
        type: dummy
        state-server: false
        tools-metadata-url: aknowndeprecatedfield
        lxc-use-clone: true
`
	var tw loggo.TestWriter
	// we only capture Warning or above
	c.Assert(loggo.RegisterWriter("invalid-env-tester", &tw, loggo.WARNING), gc.IsNil)
	defer loggo.RemoveWriter("invalid-env-tester")

	envs, err := environs.ReadEnvironsBytes([]byte(content))
	c.Check(err, jc.ErrorIsNil)
	names := envs.Names()
	sort.Strings(names)
	c.Check(names, gc.DeepEquals, []string{"deprecated", "valid"})
	// There should be no warning in the log
	c.Check(tw.Log(), gc.HasLen, 0)
	// Now we actually grab the 'valid' entry
	_, err = envs.Config("valid")
	c.Check(err, jc.ErrorIsNil)
	// And still we have no warnings
	c.Check(tw.Log(), gc.HasLen, 0)
	// Only once we grab the deprecated one do we see any warnings
	_, err = envs.Config("deprecated")
	c.Check(err, jc.ErrorIsNil)
	c.Check(tw.Log(), gc.HasLen, 2)
}
開發者ID:imoapps,項目名稱:juju,代碼行數:39,代碼來源:config_test.go

示例8: checkDeprecationWarning

func (s *ConfigDeprecationSuite) checkDeprecationWarning(c *gc.C, attrs testing.Attrs, expectedMsg string) {
	content := `
environments:
    deprecated:
        type: dummy
        controller: false
`
	restore := s.setupLogger(c)
	defer restore()

	envs, err := environs.ReadEnvironsBytes([]byte(content))
	c.Assert(err, jc.ErrorIsNil)
	environs.UpdateEnvironAttrs(envs, "deprecated", attrs)
	_, err = envs.Config("deprecated")
	c.Assert(err, jc.ErrorIsNil)

	var stripped string
	if log := s.writer.Log(); len(log) == 1 {
		stripped = strings.Replace(log[0].Message, "\n", "", -1)
	}

	c.Check(stripped, gc.Matches, expectedMsg)
}
開發者ID:exekias,項目名稱:juju,代碼行數:23,代碼來源:config_test.go

示例9: TestBoilerPlateGeneration

func (*BoilerplateConfigSuite) TestBoilerPlateGeneration(c *gc.C) {
	defer osenv.SetJujuHome(osenv.SetJujuHome(c.MkDir()))
	boilerplate_text := environs.BoilerplateConfig()
	_, err := environs.ReadEnvironsBytes([]byte(boilerplate_text))
	c.Assert(err, gc.IsNil)
}
開發者ID:klyachin,項目名稱:juju,代碼行數:6,代碼來源:boilerplate_config_test.go


注:本文中的github.com/juju/juju/environs.ReadEnvironsBytes函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。