Skip to content

Commit

Permalink
fix transformation error reporting (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
thediveo authored Nov 2, 2021
1 parent 61cd3b8 commit e001fab
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion matchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ func Not(matcher types.GomegaMatcher) types.GomegaMatcher {
// Expect(1).To(WithTransform(plus1, Equal(2))
//
// var failingplus1 = func(i int) (int, error) { return 42, "this does not compute" }
// Expect(1).To(WithTrafo(failingplus1, Equal(2)))
// Expect(1).To(WithTransform(failingplus1, Equal(2)))
//
//And(), Or(), Not() and WithTransform() allow matchers to be composed into complex expressions.
func WithTransform(transform interface{}, matcher types.GomegaMatcher) types.GomegaMatcher {
Expand Down
2 changes: 1 addition & 1 deletion matchers/with_transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (m *WithTransformMatcher) Match(actual interface{}) (bool, error) {
result := fn.Call([]reflect.Value{param})
if len(result) == 2 {
if !result[1].IsNil() {
return false, fmt.Errorf("Transform function failed: %e", result[1].Interface())
return false, fmt.Errorf("Transform function failed: %s", result[1].Interface().(error).Error())
}
}
m.transformedValue = result[0].Interface() // expect exactly one value
Expand Down
2 changes: 1 addition & 1 deletion matchers/with_transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ var _ = Describe("WithTransformMatcher", func() {
success, err := WithTransform(trafo, Equal(actual)).Match(actual)
Expect(success).To(BeFalse())
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("that does not transform"))
Expect(err.Error()).To(MatchRegexp(": that does not transform$"))
})
})

Expand Down

0 comments on commit e001fab

Please sign in to comment.