当前位置: 首页>>代码示例>>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;未经允许,请勿转载。