Skip to content

Commit

Permalink
improve eventually failure message output
Browse files Browse the repository at this point in the history
  • Loading branch information
onsi committed Jan 23, 2023
1 parent 21f3090 commit c530fb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/async_assertion.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
message += renderError(fmt.Sprintf("The function passed to %s returned the following error:", assertion.asyncType), actualErr)
}
if hasLastValidActual {
message += fmt.Sprintf("\nAt one point, however, the function did return successfully. But %s failed because", assertion.asyncType)
message += fmt.Sprintf("\nAt one point, however, the function did return successfully.\nYet, %s failed because", assertion.asyncType)
_, e := matcher.Match(lastValidActual)
if e != nil {
message += renderError(" the matcher returned the following error:", e)
Expand Down
8 changes: 4 additions & 4 deletions internal/async_assertion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ var _ = Describe("Asynchronous Assertions", func() {
}).WithTimeout(100 * time.Millisecond).WithPolling(10 * time.Millisecond).Should(Equal(10))
Ω(ig.FailureMessage).Should(ContainSubstring("The function passed to Eventually failed at %s:%d with:\nExpected\n <int>: ", file, line+3))
Ω(ig.FailureMessage).Should(ContainSubstring("to be <\n <int>: 3"))
Ω(ig.FailureMessage).Should(ContainSubstring("At one point, however, the function did return successfully. But Eventually failed because the matcher was not satisfied:\nExpected\n <int>: 2\nto equal\n <int>: 10"))
Ω(ig.FailureMessage).Should(ContainSubstring("At one point, however, the function did return successfully.\nYet, Eventually failed because the matcher was not satisfied:\nExpected\n <int>: 2\nto equal\n <int>: 10"))
})
})

Expand Down Expand Up @@ -1445,7 +1445,7 @@ sprocket:

Ω(ig.FailureMessage).Should(ContainSubstring("Timed out after"))
Ω(ig.FailureMessage).Should(ContainSubstring("told to try again after 10s: bam"))
Ω(ig.FailureMessage).Should(ContainSubstring("At one point, however, the function did return successfully. But Eventually failed because the matcher was not satisfied:\nExpected\n <int>: 2\nto equal\n <int>: 4"))
Ω(ig.FailureMessage).Should(ContainSubstring("At one point, however, the function did return successfully.\nYet, Eventually failed because the matcher was not satisfied:\nExpected\n <int>: 2\nto equal\n <int>: 4"))
})
})

Expand Down Expand Up @@ -1592,7 +1592,7 @@ sprocket:
return false, nil
}), "My Description")
Ω(ig.FailureMessage).Should(ContainSubstring("My Description\nThe function passed to Eventually returned the following error:\nactual-err\n <*errors.errorString"))
Ω(ig.FailureMessage).Should(ContainSubstring("At one point, however, the function did return successfully. But Eventually failed because the matcher returned the following error:\nmatcher-err"))
Ω(ig.FailureMessage).Should(ContainSubstring("At one point, however, the function did return successfully.\nYet, Eventually failed because the matcher returned the following error:\nmatcher-err"))
})
})

Expand All @@ -1611,7 +1611,7 @@ sprocket:
return actualInt > 3, nil
}), "My Description")
Ω(ig.FailureMessage).Should(ContainSubstring("My Description\nThe function passed to Eventually returned the following error:\nactual-err\n <*errors.errorString"))
Ω(ig.FailureMessage).Should(ContainSubstring("At one point, however, the function did return successfully. But Eventually failed because the matcher was not satisfied:\nQM failure message: 3"))
Ω(ig.FailureMessage).Should(ContainSubstring("At one point, however, the function did return successfully.\nYet, Eventually failed because the matcher was not satisfied:\nQM failure message: 3"))

})
})
Expand Down

0 comments on commit c530fb3

Please sign in to comment.