OLD | NEW |
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 deployer_test | 4 package deployer_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 | 10 |
11 "launchpad.net/juju-core/juju/testing" | 11 "launchpad.net/juju-core/juju/testing" |
12 "launchpad.net/juju-core/state" | 12 "launchpad.net/juju-core/state" |
13 "launchpad.net/juju-core/state/api" | 13 "launchpad.net/juju-core/state/api" |
14 "launchpad.net/juju-core/state/api/deployer" | 14 "launchpad.net/juju-core/state/api/deployer" |
15 "launchpad.net/juju-core/state/api/params" | 15 "launchpad.net/juju-core/state/api/params" |
16 statetesting "launchpad.net/juju-core/state/testing" | 16 statetesting "launchpad.net/juju-core/state/testing" |
17 coretesting "launchpad.net/juju-core/testing" | 17 coretesting "launchpad.net/juju-core/testing" |
| 18 jc "launchpad.net/juju-core/testing/checkers" |
18 ) | 19 ) |
19 | 20 |
20 func TestAll(t *stdtesting.T) { | 21 func TestAll(t *stdtesting.T) { |
21 coretesting.MgoTestPackage(t) | 22 coretesting.MgoTestPackage(t) |
22 } | 23 } |
23 | 24 |
24 type deployerSuite struct { | 25 type deployerSuite struct { |
25 testing.JujuConnSuite | 26 testing.JujuConnSuite |
26 | 27 |
27 stateAPI *api.State | 28 stateAPI *api.State |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 83 |
83 // Note: This is really meant as a unit-test, this isn't a test that | 84 // Note: This is really meant as a unit-test, this isn't a test that |
84 // should need all of the setup we have for this test suite | 85 // should need all of the setup we have for this test suite |
85 func (s *deployerSuite) TestNew(c *gc.C) { | 86 func (s *deployerSuite) TestNew(c *gc.C) { |
86 deployer := deployer.NewState(s.stateAPI) | 87 deployer := deployer.NewState(s.stateAPI) |
87 c.Assert(deployer, gc.NotNil) | 88 c.Assert(deployer, gc.NotNil) |
88 } | 89 } |
89 | 90 |
90 func (s *deployerSuite) assertUnauthorized(c *gc.C, err error) { | 91 func (s *deployerSuite) assertUnauthorized(c *gc.C, err error) { |
91 c.Assert(err, gc.ErrorMatches, "permission denied") | 92 c.Assert(err, gc.ErrorMatches, "permission denied") |
92 » c.Assert(params.ErrCode(err), gc.Equals, params.CodeUnauthorized) | 93 » c.Assert(err, jc.Satisfies, params.IsCodeUnauthorized) |
93 } | 94 } |
94 | 95 |
95 func (s *deployerSuite) TestWatchUnitsWrongMachine(c *gc.C) { | 96 func (s *deployerSuite) TestWatchUnitsWrongMachine(c *gc.C) { |
96 // Try with a non-existent machine tag. | 97 // Try with a non-existent machine tag. |
97 machine, err := s.st.Machine("machine-42") | 98 machine, err := s.st.Machine("machine-42") |
98 c.Assert(err, gc.IsNil) | 99 c.Assert(err, gc.IsNil) |
99 w, err := machine.WatchUnits() | 100 w, err := machine.WatchUnits() |
100 s.assertUnauthorized(c, err) | 101 s.assertUnauthorized(c, err) |
101 c.Assert(w, gc.IsNil) | 102 c.Assert(w, gc.IsNil) |
102 | 103 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 addresses, err := s.st.APIAddresses() | 252 addresses, err := s.st.APIAddresses() |
252 c.Assert(err, gc.IsNil) | 253 c.Assert(err, gc.IsNil) |
253 c.Assert(addresses, gc.DeepEquals, apiInfo.Addrs) | 254 c.Assert(addresses, gc.DeepEquals, apiInfo.Addrs) |
254 } | 255 } |
255 | 256 |
256 func (s *deployerSuite) TestCACert(c *gc.C) { | 257 func (s *deployerSuite) TestCACert(c *gc.C) { |
257 caCert, err := s.st.CACert() | 258 caCert, err := s.st.CACert() |
258 c.Assert(err, gc.IsNil) | 259 c.Assert(err, gc.IsNil) |
259 c.Assert(caCert, gc.DeepEquals, s.State.CACert()) | 260 c.Assert(caCert, gc.DeepEquals, s.State.CACert()) |
260 } | 261 } |
OLD | NEW |