Пример #1
0
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
// 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
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
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
// 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))
}