LEFT | RIGHT |
1 // Copyright 2013 Canonical Ltd. | 1 // Copyright 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 maas | 4 package maas |
5 | 5 |
6 import ( | 6 import ( |
7 gc "launchpad.net/gocheck" | 7 gc "launchpad.net/gocheck" |
8 | 8 |
9 "launchpad.net/juju-core/environs" | 9 "launchpad.net/juju-core/environs" |
10 "launchpad.net/juju-core/testing" | 10 "launchpad.net/juju-core/testing" |
11 ) | 11 ) |
12 | 12 |
13 type configSuite struct { | 13 type configSuite struct { |
14 testing.LoggingSuite | 14 testing.LoggingSuite |
15 } | 15 } |
16 | 16 |
17 var _ = gc.Suite(&configSuite{}) | 17 var _ = gc.Suite(&configSuite{}) |
18 | 18 |
19 // copyAttrs copies values from src into dest. If src contains a key that was | 19 // copyAttrs copies values from src into dest. If src contains a key that was |
20 // already in dest, its value in dest will still be updated to the one from | 20 // already in dest, its value in dest will still be updated to the one from |
21 // src. | 21 // src. |
22 func copyAttrs(src, dest map[string]interface{}) { | 22 func copyAttrs(src, dest map[string]interface{}) { |
23 for k, v := range src { | 23 for k, v := range src { |
24 dest[k] = v | 24 dest[k] = v |
25 } | 25 } |
26 } | 26 } |
27 | 27 |
28 // newConfig creates a MAAS environment config from attributes. | 28 // newConfig creates a MAAS environment config from attributes. |
29 func newConfig(values map[string]interface{}) (*maasEnvironConfig, error) { | 29 func newConfig(values map[string]interface{}) (*maasEnvironConfig, error) { |
30 » attrs := testing.FakeConfig.Merge(testing.Attrs{ | 30 » attrs := testing.FakeConfig().Merge(testing.Attrs{ |
31 "name": "testenv", | 31 "name": "testenv", |
32 "type": "maas", | 32 "type": "maas", |
33 }).Merge(values) | 33 }).Merge(values) |
34 env, err := environs.NewFromAttrs(attrs) | 34 env, err := environs.NewFromAttrs(attrs) |
35 if err != nil { | 35 if err != nil { |
36 return nil, err | 36 return nil, err |
37 } | 37 } |
38 return env.(*maasEnviron).ecfg(), nil | 38 return env.(*maasEnviron).ecfg(), nil |
39 } | 39 } |
40 | 40 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 c.Assert(err, gc.IsNil) | 83 c.Assert(err, gc.IsNil) |
84 newName := oldCfg.Name() + "-but-different" | 84 newName := oldCfg.Name() + "-but-different" |
85 newCfg, err := oldCfg.Apply(map[string]interface{}{"name": newName}) | 85 newCfg, err := oldCfg.Apply(map[string]interface{}{"name": newName}) |
86 c.Assert(err, gc.IsNil) | 86 c.Assert(err, gc.IsNil) |
87 | 87 |
88 _, err = maasEnvironProvider{}.Validate(newCfg, oldCfg.Config) | 88 _, err = maasEnvironProvider{}.Validate(newCfg, oldCfg.Config) |
89 | 89 |
90 c.Assert(err, gc.NotNil) | 90 c.Assert(err, gc.NotNil) |
91 c.Check(err, gc.ErrorMatches, ".*cannot change name.*") | 91 c.Check(err, gc.ErrorMatches, ".*cannot change name.*") |
92 } | 92 } |
LEFT | RIGHT |