Merge lp://staging/~rogpeppe/juju-core/559-fix-err-deepequals into lp://staging/~go-bot/juju-core/trunk
Proposed by
Roger Peppe
Status: | Work in progress |
---|---|
Proposed branch: | lp://staging/~rogpeppe/juju-core/559-fix-err-deepequals |
Merge into: | lp://staging/~go-bot/juju-core/trunk |
Diff against target: |
99 lines (+14/-12) 4 files modified
state/machine_test.go (+4/-2) testing/locking_test.go (+6/-5) utils/apt_test.go (+2/-4) worker/instancepoller/aggregate_test.go (+2/-1) |
To merge this branch: | bzr merge lp://staging/~rogpeppe/juju-core/559-fix-err-deepequals |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+216540@code.staging.launchpad.net |
Commit message
various: fix error DeepEquals comparisons
We should not be comparing errors with DeepEquals
in general - they have private fields, and this will
break when using adding trace information with errgo.
Description of the change
various: fix error DeepEquals comparisons
We should not be comparing errors with DeepEquals
in general - they have private fields, and this will
break when using adding trace information with errgo.
To post a comment you must log in.
Unmerged revisions
- 2654. By Roger Peppe
-
merge trunk
- 2653. By Roger Peppe
-
various: fix error deepequal comparisons in tests
Reviewers: mp+216540_ code.launchpad. net,
Message:
Please take a look.
Description:
various: fix error DeepEquals comparisons
We should not be comparing errors with DeepEquals
in general - they have private fields, and this will
break when using adding trace information with errgo.
https:/ /code.launchpad .net/~rogpeppe/ juju-core/ 559-fix- err-deepequals/ +merge/ 216540
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/89660043/
Affected files (+16, -12 lines): test.go locking_ test.go instancepoller/ aggregate_ test.go
A [revision details]
M state/machine_
M testing/
M utils/apt_test.go
M worker/
Index: [revision details] 20140418183250- hzz3f8zpw6ift0a z
=== 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: tarmac-
+New revision: <email address hidden>
Index: state/machine_ test.go machine_ test.go' test.go 2014-04-18 16:37:28 +0000 test.go 2014-04-20 12:41:40 +0000 HasContainersEr ror{}) EnsureDead( ) HasContainersEr ror{}) s.machine. Life(), gc.Equals, state.Alive)
=== modified file 'state/
--- state/machine_
+++ state/machine_
@@ -137,7 +137,8 @@
c.Assert(err, gc.FitsTypeOf, &state.
c.Assert(err, gc.ErrorMatches, `machine 1 is hosting
containers "1/lxc/0"`)
err1 := s.machine.
- c.Assert(err1, gc.DeepEquals, err)
+ c.Assert(err1, gc.FitsTypeOf, &state.
+ c.Assert(err1, gc.ErrorMatches, `machine 1 is hosting
containers "1/lxc/0"`)
c.Assert(
}
@@ -152,7 +153,8 @@ HasAssignedUnit sError{ }) EnsureDead( ) HasAssignedUnit sError{ }) s.machine. Life(), gc.Equals, state.Alive)
c.Assert(err, gc.FitsTypeOf, &state.
c.Assert(err, gc.ErrorMatches, `machine 1 has unit "wordpress/0"
assigned`)
err1 := s.machine.
- c.Assert(err1, gc.DeepEquals, err)
+ c.Assert(err, gc.FitsTypeOf, &state.
+ c.Assert(err, gc.ErrorMatches, `machine 1 has unit "wordpress/0"
assigned`)
c.Assert(
// Once no unit is assigned, lifecycle can advance.
Index: testing/ locking_ test.go locking_ test.go' locking_ test.go 2013-08-19 11:20:02 +0000 locking_ test.go 2014-04-20 12:40:45 +0000
=== modified file 'testing/
--- testing/
+++ testing/
@@ -4,7 +4,6 @@
package testing
import (
- "errors"
"sync"
gc "launchpad. net/gocheck" tion(&lock, function) }, New("function did not obey lock"))
@@ -29,8 +28,9 @@
function := func() {}
c.Check(
func() { TestLockingFunc
- gc.Panics,
- errors.
+ gc.PanicMatches,
+ "function did not obey lock",
+ )
}
func (LockingSuite) TestTestLocking FunctionDetects FailureToReleas eLock(c tion(&lock, function) }, New("function did not release lock"))
*gc.C) {
@@ -41,6 +41,7 @@
}
c.Check(
func() { TestLockingFunc
- gc.Panics,
- errors.
+ gc.PanicMatches,
+ "function did not release lock",
+ )
}
Index: utils/apt_test.go
=== modified file 'utils/apt_test.go'
--- utils/apt_test.go 2014-03-21 05:07:45 +0000
+++ utils/apt_test.go 2014-04-20 12:40:45 +0000
@@ -42,10 +42,9 @@
func (s *AptSuite) TestAptGetError(c *gc.C) {
const expected = `E: frobnicator failure detected`
cmdError := fmt.Errorf("error")
-...