Skip to content

Commit e001fab

Browse files
authoredNov 2, 2021
fix transformation error reporting (#479)
1 parent 61cd3b8 commit e001fab

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed
 

‎matchers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ func Not(matcher types.GomegaMatcher) types.GomegaMatcher {
492492
// Expect(1).To(WithTransform(plus1, Equal(2))
493493
//
494494
// var failingplus1 = func(i int) (int, error) { return 42, "this does not compute" }
495-
// Expect(1).To(WithTrafo(failingplus1, Equal(2)))
495+
// Expect(1).To(WithTransform(failingplus1, Equal(2)))
496496
//
497497
//And(), Or(), Not() and WithTransform() allow matchers to be composed into complex expressions.
498498
func WithTransform(transform interface{}, matcher types.GomegaMatcher) types.GomegaMatcher {

‎matchers/with_transform.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (m *WithTransformMatcher) Match(actual interface{}) (bool, error) {
6464
result := fn.Call([]reflect.Value{param})
6565
if len(result) == 2 {
6666
if !result[1].IsNil() {
67-
return false, fmt.Errorf("Transform function failed: %e", result[1].Interface())
67+
return false, fmt.Errorf("Transform function failed: %s", result[1].Interface().(error).Error())
6868
}
6969
}
7070
m.transformedValue = result[0].Interface() // expect exactly one value

‎matchers/with_transform_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ var _ = Describe("WithTransformMatcher", func() {
132132
success, err := WithTransform(trafo, Equal(actual)).Match(actual)
133133
Expect(success).To(BeFalse())
134134
Expect(err).To(HaveOccurred())
135-
Expect(err.Error()).To(ContainSubstring("that does not transform"))
135+
Expect(err.Error()).To(MatchRegexp(": that does not transform$"))
136136
})
137137
})
138138

0 commit comments

Comments
 (0)
Please sign in to comment.