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

Delta Between Two Patch Sets: provider/maas/config_test.go

Issue 13355044: environs/config: more restrictive New
Left Patch Set: environs/config: more restrictive New Created 11 years, 7 months ago
Right Patch Set: environs/config: more restrictive New Created 11 years, 7 months 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 | « provider/local/environ_test.go ('k') | provider/maas/environ_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 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
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 }
LEFTRIGHT

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