Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 upgrader_test | 4 package upgrader_test |
5 | 5 |
6 import ( | 6 import ( |
7 gc "launchpad.net/gocheck" | 7 gc "launchpad.net/gocheck" |
8 | 8 |
9 "launchpad.net/juju-core/errors" | 9 "launchpad.net/juju-core/errors" |
10 jujutesting "launchpad.net/juju-core/juju/testing" | 10 jujutesting "launchpad.net/juju-core/juju/testing" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 c.Check(realTools.URL, gc.Equals, "") | 223 c.Check(realTools.URL, gc.Equals, "") |
224 } | 224 } |
225 | 225 |
226 func (s *upgraderSuite) TestDesiredVersionNothing(c *gc.C) { | 226 func (s *upgraderSuite) TestDesiredVersionNothing(c *gc.C) { |
227 // Not an error to watch nothing | 227 // Not an error to watch nothing |
228 results, err := s.upgrader.DesiredVersion(params.Entities{}) | 228 results, err := s.upgrader.DesiredVersion(params.Entities{}) |
229 c.Assert(err, gc.IsNil) | 229 c.Assert(err, gc.IsNil) |
230 c.Check(results.Results, gc.HasLen, 0) | 230 c.Check(results.Results, gc.HasLen, 0) |
231 } | 231 } |
232 | 232 |
233 func (s *upgraderSuite) TestDesiredVersionRefusesWrongAgent(c *gc.C) { | 233 func (s *upgraderSuite) TestDesiredVersionRefusesWrongAgent(c *gc.C) { |
rog
2013/08/29 10:49:31
If we are going to make this a bulk call, you shou
jameinel
2013/08/29 11:50:05
Done.
TestDesiredVersionNoticesMixing
This is a
| |
234 anAuthorizer := s.authorizer | 234 anAuthorizer := s.authorizer |
235 anAuthorizer.Tag = "machine-12354" | 235 anAuthorizer.Tag = "machine-12354" |
236 anUpgrader, err := upgrader.NewUpgraderAPI(s.State, s.resources, anAutho rizer) | 236 anUpgrader, err := upgrader.NewUpgraderAPI(s.State, s.resources, anAutho rizer) |
237 c.Check(err, gc.IsNil) | 237 c.Check(err, gc.IsNil) |
238 args := params.Entities{ | 238 args := params.Entities{ |
239 Entities: []params.Entity{{Tag: s.rawMachine.Tag()}}, | 239 Entities: []params.Entity{{Tag: s.rawMachine.Tag()}}, |
240 } | 240 } |
241 results, err := anUpgrader.DesiredVersion(args) | 241 results, err := anUpgrader.DesiredVersion(args) |
242 // It is not an error to make the request, but the specific item is reje cted | 242 // It is not an error to make the request, but the specific item is reje cted |
243 c.Assert(err, gc.IsNil) | 243 c.Assert(err, gc.IsNil) |
244 c.Check(results.Results, gc.HasLen, 1) | 244 c.Check(results.Results, gc.HasLen, 1) |
245 toolResult := results.Results[0] | 245 toolResult := results.Results[0] |
246 c.Assert(toolResult.Error, gc.DeepEquals, apiservertesting.ErrUnauthoriz ed) | 246 c.Assert(toolResult.Error, gc.DeepEquals, apiservertesting.ErrUnauthoriz ed) |
247 } | 247 } |
248 | 248 |
249 func (s *upgraderSuite) TestDesiredVersionNoticesMixedAgents(c *gc.C) { | |
250 args := params.Entities{Entities: []params.Entity{ | |
251 {Tag: s.rawMachine.Tag()}, | |
252 {Tag: "machine-12345"}, | |
253 }} | |
254 results, err := s.upgrader.DesiredVersion(args) | |
255 c.Assert(err, gc.IsNil) | |
256 c.Check(results.Results, gc.HasLen, 2) | |
257 c.Assert(results.Results[0].Error, gc.IsNil) | |
258 agentVersion := results.Results[0].Version | |
259 c.Assert(agentVersion, gc.NotNil) | |
260 c.Check(*agentVersion, gc.DeepEquals, version.Current.Number) | |
261 | |
262 c.Assert(results.Results[1].Error, gc.DeepEquals, apiservertesting.ErrUn authorized) | |
263 c.Assert(results.Results[1].Version, gc.IsNil) | |
264 | |
265 } | |
266 | |
249 func (s *upgraderSuite) TestDesiredVersionForAgent(c *gc.C) { | 267 func (s *upgraderSuite) TestDesiredVersionForAgent(c *gc.C) { |
250 args := params.Entities{Entities: []params.Entity{{Tag: s.rawMachine.Tag ()}}} | 268 args := params.Entities{Entities: []params.Entity{{Tag: s.rawMachine.Tag ()}}} |
251 results, err := s.upgrader.DesiredVersion(args) | 269 results, err := s.upgrader.DesiredVersion(args) |
252 c.Assert(err, gc.IsNil) | 270 c.Assert(err, gc.IsNil) |
253 c.Check(results.Results, gc.HasLen, 1) | 271 c.Check(results.Results, gc.HasLen, 1) |
254 c.Assert(results.Results[0].Error, gc.IsNil) | 272 c.Assert(results.Results[0].Error, gc.IsNil) |
255 agentVersion := results.Results[0].Version | 273 agentVersion := results.Results[0].Version |
256 c.Assert(agentVersion, gc.NotNil) | 274 c.Assert(agentVersion, gc.NotNil) |
257 c.Check(*agentVersion, gc.DeepEquals, version.Current.Number) | 275 c.Check(*agentVersion, gc.DeepEquals, version.Current.Number) |
258 } | 276 } |
LEFT | RIGHT |