コード例 #1
0
ファイル: storageprovisioner_test.go プロジェクト: makyo/juju
func (s *provisionerSuite) TestModelConfig(c *gc.C) {
	stateModelConfig, err := s.State.ModelConfig()
	c.Assert(err, jc.ErrorIsNil)

	result, err := s.api.ModelConfig()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(result.Config, jc.DeepEquals, params.ModelConfig(stateModelConfig.AllAttrs()))
}
コード例 #2
0
ファイル: modelwatcher.go プロジェクト: bac/juju
// AssertModelConfig provides a method to test the config from the
// envWatcher.  This allows other tests that embed this type to have
// more than just the default test.
func (s *ModelWatcherTest) AssertModelConfig(c *gc.C, envWatcher ModelWatcher) {
	envConfig, err := s.st.ModelConfig()
	c.Assert(err, jc.ErrorIsNil)

	result, err := envWatcher.ModelConfig()
	c.Assert(err, jc.ErrorIsNil)

	configAttributes := envConfig.AllAttrs()
	c.Assert(result.Config, jc.DeepEquals, params.ModelConfig(configAttributes))
}
コード例 #3
0
ファイル: instancepoller_test.go プロジェクト: pmatulis/juju
func (s *InstancePollerSuite) TestModelConfigSuccess(c *gc.C) {
	var called int
	expectedConfig := coretesting.ModelConfig(c)
	expectedResults := params.ModelConfigResult{
		Config: params.ModelConfig(expectedConfig.AllAttrs()),
	}
	apiCaller := successAPICaller(c, "ModelConfig", nil, expectedResults, &called)

	api := instancepoller.NewAPI(apiCaller)
	cfg, err := api.ModelConfig()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(called, gc.Equals, 1)
	c.Assert(cfg, jc.DeepEquals, expectedConfig)
}
コード例 #4
0
ファイル: undertaker_test.go プロジェクト: exekias/juju
func (s *undertakerSuite) TestModelConfig(c *gc.C) {
	var called bool

	// The undertaker feature tests ensure ModelConfig is connected
	// correctly end to end. This test just ensures that the API calls work.
	client := s.mockClient(c, "ModelConfig", func(response interface{}) {
		called = true
		c.Check(response, gc.DeepEquals, &params.ModelConfigResult{Config: params.ModelConfig(nil)})
	})

	// We intentionally don't test the error here. We are only interested that
	// the ModelConfig endpoint was called.
	client.ModelConfig()
	c.Assert(called, jc.IsTrue)
}
コード例 #5
0
ファイル: modelwatcher.go プロジェクト: pmatulis/juju
// AssertModelConfig provides a method to test the config from the
// envWatcher.  This allows other tests that embed this type to have
// more than just the default test.
func (s *ModelWatcherTest) AssertModelConfig(c *gc.C, envWatcher ModelWatcher, hasSecrets bool) {
	envConfig, err := s.st.ModelConfig()
	c.Assert(err, jc.ErrorIsNil)

	result, err := envWatcher.ModelConfig()
	c.Assert(err, jc.ErrorIsNil)

	configAttributes := envConfig.AllAttrs()
	// If the implementor doesn't provide secrets, we need to replace the config
	// values in our environment to compare against with the secrets replaced.
	if !hasSecrets {
		env, err := environs.New(envConfig)
		c.Assert(err, jc.ErrorIsNil)
		secretAttrs, err := env.Provider().SecretAttrs(envConfig)
		c.Assert(err, jc.ErrorIsNil)
		for key := range secretAttrs {
			configAttributes[key] = "not available"
		}
	}

	c.Assert(result.Config, jc.DeepEquals, params.ModelConfig(configAttributes))
}