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

Unified Diff: state/apiserver/upgrader/upgrader_test.go

Issue 13380043: upgrader: add Upgrader.DesiredVersion
Patch Set: upgrader: add Upgrader.DesiredVersion Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: state/apiserver/upgrader/upgrader_test.go
=== modified file 'state/apiserver/upgrader/upgrader_test.go'
--- state/apiserver/upgrader/upgrader_test.go 2013-08-22 07:16:20 +0000
+++ state/apiserver/upgrader/upgrader_test.go 2013-08-29 11:19:39 +0000
@@ -222,3 +222,55 @@
c.Check(realTools.Version.Build, gc.Equals, cur.Build)
c.Check(realTools.URL, gc.Equals, "")
}
+
+func (s *upgraderSuite) TestDesiredVersionNothing(c *gc.C) {
+ // Not an error to watch nothing
+ results, err := s.upgrader.DesiredVersion(params.Entities{})
+ c.Assert(err, gc.IsNil)
+ c.Check(results.Results, gc.HasLen, 0)
+}
+
+func (s *upgraderSuite) TestDesiredVersionRefusesWrongAgent(c *gc.C) {
+ anAuthorizer := s.authorizer
+ anAuthorizer.Tag = "machine-12354"
+ anUpgrader, err := upgrader.NewUpgraderAPI(s.State, s.resources, anAuthorizer)
+ c.Check(err, gc.IsNil)
+ args := params.Entities{
+ Entities: []params.Entity{{Tag: s.rawMachine.Tag()}},
+ }
+ results, err := anUpgrader.DesiredVersion(args)
+ // It is not an error to make the request, but the specific item is rejected
+ c.Assert(err, gc.IsNil)
+ c.Check(results.Results, gc.HasLen, 1)
+ toolResult := results.Results[0]
+ c.Assert(toolResult.Error, gc.DeepEquals, apiservertesting.ErrUnauthorized)
+}
+
+func (s *upgraderSuite) TestDesiredVersionNoticesMixedAgents(c *gc.C) {
+ args := params.Entities{Entities: []params.Entity{
+ {Tag: s.rawMachine.Tag()},
+ {Tag: "machine-12345"},
+ }}
+ results, err := s.upgrader.DesiredVersion(args)
+ c.Assert(err, gc.IsNil)
+ c.Check(results.Results, gc.HasLen, 2)
+ c.Assert(results.Results[0].Error, gc.IsNil)
+ agentVersion := results.Results[0].Version
+ c.Assert(agentVersion, gc.NotNil)
+ c.Check(*agentVersion, gc.DeepEquals, version.Current.Number)
+
+ c.Assert(results.Results[1].Error, gc.DeepEquals, apiservertesting.ErrUnauthorized)
+ c.Assert(results.Results[1].Version, gc.IsNil)
+
+}
+
+func (s *upgraderSuite) TestDesiredVersionForAgent(c *gc.C) {
+ args := params.Entities{Entities: []params.Entity{{Tag: s.rawMachine.Tag()}}}
+ results, err := s.upgrader.DesiredVersion(args)
+ c.Assert(err, gc.IsNil)
+ c.Check(results.Results, gc.HasLen, 1)
+ c.Assert(results.Results[0].Error, gc.IsNil)
+ agentVersion := results.Results[0].Version
+ c.Assert(agentVersion, gc.NotNil)
+ c.Check(*agentVersion, gc.DeepEquals, version.Current.Number)
+}

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