コード例 #1
0
ファイル: open_test.go プロジェクト: jameinel/core
func (*OpenSuite) TestConfigForNameFromInfo(c *gc.C) {
	defer testing.MakeFakeHome(c, testing.SingleEnvConfig, testing.SampleCertName).Restore()
	store := configstore.NewMem()
	cfg, source, err := environs.ConfigForName("", store)
	c.Assert(err, gc.IsNil)
	c.Assert(source, gc.Equals, environs.ConfigFromEnvirons)

	info, err := store.CreateInfo("test-config")
	c.Assert(err, gc.IsNil)
	var attrs testing.Attrs = cfg.AllAttrs()
	attrs = attrs.Merge(testing.Attrs{
		"name": "test-config",
	})
	info.SetBootstrapConfig(attrs)
	err = info.Write()
	c.Assert(err, gc.IsNil)

	cfg, source, err = environs.ConfigForName("test-config", store)
	c.Assert(err, gc.IsNil)
	c.Assert(source, gc.Equals, environs.ConfigFromInfo)
	c.Assert(testing.Attrs(cfg.AllAttrs()), gc.DeepEquals, attrs)
}
コード例 #2
0
ファイル: config_test.go プロジェクト: jameinel/core
			"name":           "my-name",
			"logging-config": "foo=bar",
		},
		err: `unknown severity level "bar"`,
	}, {
		about:       "Sample configuration",
		useDefaults: config.UseDefaults,
		attrs:       sampleConfig,
	}, {
		about:       "No defaults: sample configuration",
		useDefaults: config.NoDefaults,
		attrs:       sampleConfig,
	}, {
		about:       "No defaults: with ca-cert-path",
		useDefaults: config.NoDefaults,
		attrs:       sampleConfig.Merge(testing.Attrs{"ca-cert-path": "arble"}),
		err:         `attribute "ca-cert-path" is not allowed in configuration`,
	}, {
		about:       "No defaults: with ca-private-key-path",
		useDefaults: config.NoDefaults,
		attrs:       sampleConfig.Merge(testing.Attrs{"ca-private-key-path": "arble"}),
		err:         `attribute "ca-private-key-path" is not allowed in configuration`,
	}, {
		about:       "No defaults: with authorized-keys-path",
		useDefaults: config.NoDefaults,
		attrs:       sampleConfig.Merge(testing.Attrs{"authorized-keys-path": "arble"}),
		err:         `attribute "authorized-keys-path" is not allowed in configuration`,
	}, {
		about:       "No defaults: missing authorized-keys",
		useDefaults: config.NoDefaults,
		attrs:       sampleConfig.Delete("authorized-keys"),