4
. "launchpad.net/gocheck"
5
"launchpad.net/juju-core/environs"
6
"launchpad.net/juju-core/environs/config"
7
"launchpad.net/juju-core/juju/testing"
8
"launchpad.net/juju-core/state"
9
coretesting "launchpad.net/juju-core/testing"
10
"launchpad.net/juju-core/worker"
19
var _ = Suite(&suite{})
21
func TestPackage(t *stdtesting.T) {
22
coretesting.MgoTestPackage(t)
25
func (s *suite) TestStop(c *C) {
26
w := s.State.WatchEnvironConfig()
27
defer stopWatcher(c, w)
28
stop := make(chan struct{})
29
done := make(chan error)
31
env, err := worker.WaitForEnviron(w, stop)
36
c.Assert(<-done, Equals, tomb.ErrDying)
39
func stopWatcher(c *C, w *state.EnvironConfigWatcher) {
44
func (s *suite) TestInvalidConfig(c *C) {
45
// Create an invalid config by taking the current config and
46
// tweaking the provider type.
47
cfg, err := s.State.EnvironConfig()
51
invalidCfg, err := config.New(m)
54
err = s.State.SetEnvironConfig(invalidCfg)
57
w := s.State.WatchEnvironConfig()
58
defer stopWatcher(c, w)
59
done := make(chan environs.Environ)
61
env, err := worker.WaitForEnviron(w, nil)
65
// Wait for the loop to process the invalid configuratrion
66
<-worker.LoadedInvalid
68
// Then load a valid configuration back in.
70
m["secret"] = "environ_test"
71
validCfg, err := config.New(m)
74
err = s.State.SetEnvironConfig(validCfg)
80
c.Assert(env.Config().AllAttrs()["secret"], Equals, "environ_test")