Merge lp://staging/~niemeyer/juju-core/drop-resolved-error-result into lp://staging/~juju/juju-core/trunk

Proposed by Gustavo Niemeyer
Status: Merged
Merged at revision: 566
Proposed branch: lp://staging/~niemeyer/juju-core/drop-resolved-error-result
Merge into: lp://staging/~juju/juju-core/trunk
Diff against target: 55 lines (+16/-10)
2 files modified
state/unit.go (+2/-2)
state/unit_test.go (+14/-8)
To merge this branch: bzr merge lp://staging/~niemeyer/juju-core/drop-resolved-error-result
Reviewer Review Type Date Requested Status
The Go Language Gophers Pending
Review via email: mp+126110@code.staging.launchpad.net

Description of the change

state: drop error result from Unit.Resolved

https://codereview.appspot.com/6570043/

To post a comment you must log in.
Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

Reviewers: mp+126110_code.launchpad.net,

Message:
Please take a look.

Description:
state: drop error result from Unit.Resolved

https://code.launchpad.net/~niemeyer/juju-core/drop-resolved-error-result/+merge/126110

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/6570043/

Affected files:
   A [revision details]
   M state/unit.go
   M state/unit_test.go

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>

Index: state/unit.go
=== modified file 'state/unit.go'
--- state/unit.go 2012-09-24 14:37:22 +0000
+++ state/unit.go 2012-09-24 21:31:51 +0000
@@ -172,8 +172,8 @@
  }

  // Resolved returns the resolved mode for the unit.
-func (u *Unit) Resolved() (mode ResolvedMode, err error) {
- return u.doc.Resolved, nil
+func (u *Unit) Resolved() ResolvedMode {
+ return u.doc.Resolved
  }

  // IsPrincipal returns whether the unit is deployed in its own container,

Index: state/unit_test.go
=== modified file 'state/unit_test.go'
--- state/unit_test.go 2012-09-24 14:37:22 +0000
+++ state/unit_test.go 2012-09-24 21:31:51 +0000
@@ -184,23 +184,29 @@
  }

  func (s *UnitSuite) TestGetSetClearResolved(c *C) {
- setting, err := s.unit.Resolved()
- c.Assert(err, IsNil)
- c.Assert(setting, Equals, state.ResolvedNone)
+ mode := s.unit.Resolved()
+ c.Assert(mode, Equals, state.ResolvedNone)

- err = s.unit.SetResolved(state.ResolvedNoHooks)
+ err := s.unit.SetResolved(state.ResolvedNoHooks)
   c.Assert(err, IsNil)
   err = s.unit.SetResolved(state.ResolvedNoHooks)
   c.Assert(err, ErrorMatches, `cannot set resolved mode for
unit "wordpress/0": already resolved`)
- retry, err := s.unit.Resolved()
+
+ mode = s.unit.Resolved()
+ c.Assert(mode, Equals, state.ResolvedNoHooks)
+ err = s.unit.Refresh()
   c.Assert(err, IsNil)
- c.Assert(retry, Equals, state.ResolvedNoHooks)
+ mode = s.unit.Resolved()
+ c.Assert(mode, Equals, state.ResolvedNoHooks)

   err = s.unit.ClearResolved()
   c.Assert(err, IsNil)
- setting, err = s.unit.Resolved()
+ mode = s.unit.Resolved()
+ c.Assert(mode, Equals, state.ResolvedNone)
+ err = s.unit.Refresh()
   c.Assert(err, IsNil)
- c.Assert(setting, Equals, state.ResolvedNone)
+ mode = s.unit.Resolved()
+ c.Assert(mode, Equals, state.ResolvedNone)
   err = s.unit.ClearResolved()
   c.Assert(err, IsNil)

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

<fwereade> niemeyer, LGTM, much nicer

https://codereview.appspot.com/6570043/

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

*** Submitted:

state: drop error result from Unit.Resolved

R=
CC=
https://codereview.appspot.com/6570043

https://codereview.appspot.com/6570043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches