Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(47)

Delta Between Two Patch Sets: worker/environ_test.go

Issue 70190050: Update and Validate Environ Config in State
Left Patch Set: Update and validate environ config in state Created 11 years, 1 month ago
Right Patch Set: Update and Validate Environ Config in State Created 11 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « worker/authenticationworker/worker_test.go ('k') | worker/firewaller/firewaller_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2012, 2013 Canonical Ltd. 1 // Copyright 2012, 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package worker_test 4 package worker_test
5 5
6 import ( 6 import (
7 stdtesting "testing" 7 stdtesting "testing"
8 8
9 gc "launchpad.net/gocheck" 9 gc "launchpad.net/gocheck"
10 "launchpad.net/tomb" 10 "launchpad.net/tomb"
11 11
12 "launchpad.net/juju-core/environs"
12 "launchpad.net/juju-core/juju/testing" 13 "launchpad.net/juju-core/juju/testing"
13 "launchpad.net/juju-core/state" 14 "launchpad.net/juju-core/state"
14 coretesting "launchpad.net/juju-core/testing" 15 coretesting "launchpad.net/juju-core/testing"
15 "launchpad.net/juju-core/worker" 16 "launchpad.net/juju-core/worker"
16 ) 17 )
17 18
18 type waitForEnvironSuite struct { 19 type waitForEnvironSuite struct {
19 testing.JujuConnSuite 20 testing.JujuConnSuite
20 } 21 }
21 22
(...skipping 14 matching lines...) Expand all
36 done <- err 37 done <- err
37 }() 38 }()
38 close(stop) 39 close(stop)
39 c.Assert(<-done, gc.Equals, tomb.ErrDying) 40 c.Assert(<-done, gc.Equals, tomb.ErrDying)
40 } 41 }
41 42
42 func stopWatcher(c *gc.C, w state.NotifyWatcher) { 43 func stopWatcher(c *gc.C, w state.NotifyWatcher) {
43 err := w.Stop() 44 err := w.Stop()
44 c.Check(err, gc.IsNil) 45 c.Check(err, gc.IsNil)
45 } 46 }
47
48 func (s *waitForEnvironSuite) TestInvalidConfig(c *gc.C) {
49 var oldType string
50 oldType = s.Conn.Environ.Config().AllAttrs()["type"].(string)
51
52 // Create an invalid config by taking the current config and
53 // tweaking the provider type.
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)
58 defer st2.Close()
59 err = st2.UpdateEnvironConfig(map[string]interface{}{"type": "unknown"}, nil, nil)
60 c.Assert(err, gc.IsNil)
61
62 w := st2.WatchForEnvironConfigChanges()
63 defer stopWatcher(c, w)
64 done := make(chan environs.Environ)
65 go func() {
66 env, err := worker.WaitForEnviron(w, st2, nil)
67 c.Check(err, gc.IsNil)
68 done <- env
69 }()
70 // Wait for the loop to process the invalid configuratrion
71 <-worker.LoadedInvalid
72
73 st2.UpdateEnvironConfig(map[string]interface{}{
74 "type": oldType,
75 "secret": "environ_test",
76 }, nil, nil)
77
78 env := <-done
79 c.Assert(env, gc.NotNil)
80 c.Assert(env.Config().AllAttrs()["secret"], gc.Equals, "environ_test")
81 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b