~rogpeppe/juju-core/438-local-instance-Addresses

« back to all changes in this revision

Viewing changes to worker/environ_test.go

worker: fix test

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
        "launchpad.net/tomb"
11
11
 
12
12
        "launchpad.net/juju-core/environs"
13
 
        "launchpad.net/juju-core/environs/config"
14
13
        "launchpad.net/juju-core/juju/testing"
15
14
        "launchpad.net/juju-core/state"
16
15
        coretesting "launchpad.net/juju-core/testing"
21
20
        testing.JujuConnSuite
22
21
}
23
22
 
24
 
var _ = gc.Suite(&suite{})
 
23
var _ = gc.Suite(&waitForEnvironSuite{})
25
24
 
26
25
func TestPackage(t *stdtesting.T) {
27
26
        coretesting.MgoTestPackage(t)
49
48
func (s *waitForEnvironSuite) TestInvalidConfig(c *gc.C) {
50
49
        // Create an invalid config by taking the current config and
51
50
        // tweaking the provider type.
 
51
        var oldType string
52
52
        testing.ChangeEnvironConfig(c, s.State, func(attrs coretesting.Attrs) coretesting.Attrs {
 
53
                oldType = attrs["type"].(string)
53
54
                return attrs.Merge(coretesting.Attrs{"type": "unknown"})
54
55
        })
55
56
        w := s.State.WatchForEnvironConfigChanges()
63
64
        // Wait for the loop to process the invalid configuratrion
64
65
        <-worker.LoadedInvalid
65
66
 
66
 
        // Then load a valid configuration back in.
67
 
        m = cfg.AllAttrs()
68
 
        m["secret"] = "environ_test"
69
 
        validCfg, err := config.New(config.NoDefaults, m)
70
 
        c.Assert(err, gc.IsNil)
71
 
 
72
 
        err = s.State.SetEnvironConfig(validCfg)
73
 
        c.Assert(err, gc.IsNil)
74
 
        s.State.StartSync()
 
67
        testing.ChangeEnvironConfig(c, s.State, func(attrs coretesting.Attrs) coretesting.Attrs {
 
68
                return attrs.Merge(coretesting.Attrs{
 
69
                        "type":   oldType,
 
70
                        "secret": "environ_test",
 
71
                })
 
72
        })
75
73
 
76
74
        env := <-done
77
75
        c.Assert(env, gc.NotNil)