Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

state: use errors.Cause in IsNotAssigned #1789

Merged
merged 1 commit into from
Mar 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion state/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ func (e *NotAssignedError) Error() string {

// IsNotAssigned verifies that err is an instance of NotAssignedError
func IsNotAssigned(err error) bool {
_, ok := err.(*NotAssignedError)
_, ok := errors.Cause(err).(*NotAssignedError)
return ok
}

Expand Down
10 changes: 5 additions & 5 deletions state/unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1059,15 +1059,15 @@ func (s *UnitSuite) TestOpenedPorts(c *gc.C) {
// Verify ports can be opened and closed only when the unit has
// assigned machine.
err := s.unit.OpenPort("tcp", 10)
c.Assert(errors.Cause(err), jc.Satisfies, state.IsNotAssigned)
c.Assert(err, jc.Satisfies, state.IsNotAssigned)
err = s.unit.OpenPorts("tcp", 10, 20)
c.Assert(errors.Cause(err), jc.Satisfies, state.IsNotAssigned)
c.Assert(err, jc.Satisfies, state.IsNotAssigned)
err = s.unit.ClosePort("tcp", 10)
c.Assert(errors.Cause(err), jc.Satisfies, state.IsNotAssigned)
c.Assert(err, jc.Satisfies, state.IsNotAssigned)
err = s.unit.ClosePorts("tcp", 10, 20)
c.Assert(errors.Cause(err), jc.Satisfies, state.IsNotAssigned)
c.Assert(err, jc.Satisfies, state.IsNotAssigned)
open, err := s.unit.OpenedPorts()
c.Assert(errors.Cause(err), jc.Satisfies, state.IsNotAssigned)
c.Assert(err, jc.Satisfies, state.IsNotAssigned)
c.Assert(open, gc.HasLen, 0)

machine, err := s.State.AddMachine("quantal", state.JobHostUnits)
Expand Down