Exemplo n.º 1
0
func (s *provisionerSuite) TestEnvironConfig(c *gc.C) {
	stateEnvironConfig, err := s.State.EnvironConfig()
	c.Assert(err, jc.ErrorIsNil)

	result, err := s.api.EnvironConfig()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(result.Config, jc.DeepEquals, params.EnvironConfig(stateEnvironConfig.AllAttrs()))
}
Exemplo n.º 2
0
func (s *InstancePollerSuite) TestEnvironConfigSuccess(c *gc.C) {
	var called int
	expectedConfig := coretesting.EnvironConfig(c)
	expectedResults := params.EnvironConfigResult{
		Config: params.EnvironConfig(expectedConfig.AllAttrs()),
	}
	apiCaller := successAPICaller(c, "EnvironConfig", nil, expectedResults, &called)

	api := instancepoller.NewAPI(apiCaller)
	cfg, err := api.EnvironConfig()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(called, gc.Equals, 1)
	c.Assert(cfg, jc.DeepEquals, expectedConfig)
}
Exemplo n.º 3
0
func (s *undertakerSuite) TestEnvironConfig(c *gc.C) {
	var called bool

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

	// We intentionally don't test the error here. We are only interested that
	// the EnvironConfig endpoint was called.
	client.EnvironConfig()
	c.Assert(called, jc.IsTrue)
}
Exemplo n.º 4
0
// AssertEnvironConfig 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 *EnvironWatcherTest) AssertEnvironConfig(c *gc.C, envWatcher EnvironmentWatcher, hasSecrets bool) {
	envConfig, err := s.st.EnvironConfig()
	c.Assert(err, jc.ErrorIsNil)

	result, err := envWatcher.EnvironConfig()
	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.EnvironConfig(configAttributes))
}