OLD | NEW |
1 package state | 1 package state |
2 | 2 |
3 import ( | 3 import ( |
4 . "launchpad.net/gocheck" | 4 . "launchpad.net/gocheck" |
5 "launchpad.net/juju-core/testing" | 5 "launchpad.net/juju-core/testing" |
6 ) | 6 ) |
7 | 7 |
8 type SettingsSuite struct { | 8 type SettingsSuite struct { |
| 9 testing.LoggingSuite |
9 testing.MgoSuite | 10 testing.MgoSuite |
10 state *State | 11 state *State |
11 key string | 12 key string |
12 } | 13 } |
13 | 14 |
14 var _ = Suite(&SettingsSuite{}) | 15 var _ = Suite(&SettingsSuite{}) |
15 | 16 |
16 // TestingStateInfo returns information suitable for | 17 // TestingStateInfo returns information suitable for |
17 // connecting to the testing state server. | 18 // connecting to the testing state server. |
18 func TestingStateInfo() *Info { | 19 func TestingStateInfo() *Info { |
19 return &Info{ | 20 return &Info{ |
20 Addrs: []string{testing.MgoAddr}, | 21 Addrs: []string{testing.MgoAddr}, |
21 CACert: []byte(testing.CACert), | 22 CACert: []byte(testing.CACert), |
22 } | 23 } |
23 } | 24 } |
24 | 25 |
| 26 func (s *SettingsSuite) SetUpSuite(c *C) { |
| 27 s.LoggingSuite.SetUpSuite(c) |
| 28 s.MgoSuite.SetUpSuite(c) |
| 29 } |
| 30 |
| 31 func (s *SettingsSuite) TearDownSuite(c *C) { |
| 32 s.MgoSuite.TearDownSuite(c) |
| 33 s.LoggingSuite.TearDownSuite(c) |
| 34 } |
| 35 |
25 func (s *SettingsSuite) SetUpTest(c *C) { | 36 func (s *SettingsSuite) SetUpTest(c *C) { |
| 37 s.LoggingSuite.SetUpTest(c) |
26 s.MgoSuite.SetUpTest(c) | 38 s.MgoSuite.SetUpTest(c) |
27 state, err := Open(TestingStateInfo()) | 39 state, err := Open(TestingStateInfo()) |
28 c.Assert(err, IsNil) | 40 c.Assert(err, IsNil) |
29 | 41 |
30 s.state = state | 42 s.state = state |
31 s.key = "config" | 43 s.key = "config" |
32 } | 44 } |
33 | 45 |
34 func (s *SettingsSuite) TearDownTest(c *C) { | 46 func (s *SettingsSuite) TearDownTest(c *C) { |
35 s.state.Close() | 47 s.state.Close() |
36 s.MgoSuite.TearDownTest(c) | 48 s.MgoSuite.TearDownTest(c) |
| 49 s.LoggingSuite.TearDownTest(c) |
37 } | 50 } |
38 | 51 |
39 func (s *SettingsSuite) TestCreateEmptySettings(c *C) { | 52 func (s *SettingsSuite) TestCreateEmptySettings(c *C) { |
40 node, err := createSettings(s.state, s.key, nil) | 53 node, err := createSettings(s.state, s.key, nil) |
41 c.Assert(err, IsNil) | 54 c.Assert(err, IsNil) |
42 c.Assert(node.Keys(), DeepEquals, []string{}) | 55 c.Assert(node.Keys(), DeepEquals, []string{}) |
43 } | 56 } |
44 | 57 |
45 func (s *SettingsSuite) TestCannotOverwrite(c *C) { | 58 func (s *SettingsSuite) TestCannotOverwrite(c *C) { |
46 _, err := createSettings(s.state, s.key, nil) | 59 _, err := createSettings(s.state, s.key, nil) |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 changes, err = nodeOne.Write() | 378 changes, err = nodeOne.Write() |
366 c.Assert(err, IsNil) | 379 c.Assert(err, IsNil) |
367 c.Assert(changes, DeepEquals, []ItemChange{}) | 380 c.Assert(changes, DeepEquals, []ItemChange{}) |
368 | 381 |
369 err = nodeOne.Read() | 382 err = nodeOne.Read() |
370 c.Assert(err, IsNil) | 383 c.Assert(err, IsNil) |
371 c.Assert(nodeOne.key, Equals, nodeTwo.key) | 384 c.Assert(nodeOne.key, Equals, nodeTwo.key) |
372 c.Assert(nodeOne.disk, DeepEquals, nodeTwo.disk) | 385 c.Assert(nodeOne.disk, DeepEquals, nodeTwo.disk) |
373 c.Assert(nodeOne.core, DeepEquals, nodeTwo.core) | 386 c.Assert(nodeOne.core, DeepEquals, nodeTwo.core) |
374 } | 387 } |
OLD | NEW |