48
48
func (s *waitForEnvironSuite) TestInvalidConfig(c *gc.C) {
50
oldType = s.Conn.Environ.Config().AllAttrs()["type"].(string)
49
52
// Create an invalid config by taking the current config and
50
53
// tweaking the provider type.
52
testing.ChangeEnvironConfig(c, s.State, func(attrs coretesting.Attrs) coretesting.Attrs {
53
oldType = attrs["type"].(string)
54
return attrs.Merge(coretesting.Attrs{"type": "unknown"})
56
w := s.State.WatchForEnvironConfigChanges()
54
info := s.StateInfo(c)
55
opts := state.DefaultDialOpts()
56
st2, err := state.Open(info, opts, state.Policy(nil))
57
c.Assert(err, gc.IsNil)
59
err = st2.UpdateEnvironConfig(map[string]interface{}{"type": "unknown"}, nil, nil)
60
c.Assert(err, gc.IsNil)
62
w := st2.WatchForEnvironConfigChanges()
57
63
defer stopWatcher(c, w)
58
64
done := make(chan environs.Environ)
60
env, err := worker.WaitForEnviron(w, s.State, nil)
66
env, err := worker.WaitForEnviron(w, st2, nil)
61
67
c.Check(err, gc.IsNil)
64
70
// Wait for the loop to process the invalid configuratrion
65
71
<-worker.LoadedInvalid
67
testing.ChangeEnvironConfig(c, s.State, func(attrs coretesting.Attrs) coretesting.Attrs {
68
return attrs.Merge(coretesting.Attrs{
70
"secret": "environ_test",
73
st2.UpdateEnvironConfig(map[string]interface{}{
75
"secret": "environ_test",
75
79
c.Assert(env, gc.NotNil)