Skip to content

Commit 8e9d214

Browse files
alexandeardolmen
andcommitted
Apply suggestions from code review
Co-authored-by: Olivier Mengué <[email protected]>
1 parent d57bac8 commit 8e9d214

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

Diff for: assert/assertion_compare.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedCompare
468468

469469
compareResult, isComparable := compare(e1, e2, e1Kind)
470470
if !isComparable {
471-
return Fail(t, fmt.Sprintf("Can not compare type %q", reflect.TypeOf(e1)), msgAndArgs...)
471+
return Fail(t, fmt.Sprintf(`Can not compare type "%T"`, e1), msgAndArgs...)
472472
}
473473

474474
if !containsValue(allowedComparesResults, compareResult) {

Diff for: assert/assertion_order.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func isOrdered(t TestingT, object interface{}, allowedComparesResults []compareR
3333
compareResult, isComparable := compare(prevValueInterface, valueInterface, firstValueKind)
3434

3535
if !isComparable {
36-
return Fail(t, fmt.Sprintf("Can not compare type %q and %q", reflect.TypeOf(value), reflect.TypeOf(prevValue)), msgAndArgs...)
36+
return Fail(t, fmt.Sprintf(`Can not compare type "%T" and "%T"`, value, prevValue), msgAndArgs...)
3737
}
3838

3939
if !containsValue(allowedComparesResults, compareResult) {

Diff for: assert/assertions_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -2151,23 +2151,23 @@ func TestZero(t *testing.T) {
21512151
mockT := new(testing.T)
21522152

21532153
for _, test := range zeros {
2154-
True(t, Zero(mockT, test, "%#v is not the %v zero value", test, reflect.TypeOf(test)))
2154+
True(t, Zero(mockT, test, "%#v is not the %T zero value", test, test))
21552155
}
21562156

21572157
for _, test := range nonZeros {
2158-
False(t, Zero(mockT, test, "%#v is not the %v zero value", test, reflect.TypeOf(test)))
2158+
False(t, Zero(mockT, test, "%#v is not the %T zero value", test, test))
21592159
}
21602160
}
21612161

21622162
func TestNotZero(t *testing.T) {
21632163
mockT := new(testing.T)
21642164

21652165
for _, test := range zeros {
2166-
False(t, NotZero(mockT, test, "%#v is not the %v zero value", test, reflect.TypeOf(test)))
2166+
False(t, NotZero(mockT, test, "%#v is not the %T zero value", test, test))
21672167
}
21682168

21692169
for _, test := range nonZeros {
2170-
True(t, NotZero(mockT, test, "%#v is not the %v zero value", test, reflect.TypeOf(test)))
2170+
True(t, NotZero(mockT, test, "%#v is not the %T zero value", test, test))
21712171
}
21722172
}
21732173

Diff for: mock/mock.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ func (m *Mock) MethodCalled(methodName string, arguments ...interface{}) Argumen
494494
// expected call found, but it has already been called with repeatable times
495495
if call != nil {
496496
m.mutex.Unlock()
497-
m.fail("\nassert: mock: The method has been called over %d times.\n\tEither do one more Mock.On(%q).Return(...), or remove extra call.\n\tThis call was unexpected:\n\t\t%s\n\tat: %s", call.totalCalls, methodName, callString(methodName, arguments, true), assert.CallerInfo())
497+
m.fail("\nassert: mock: The method has been called over %d times.\n\tEither do one more Mock.On(%#v).Return(...), or remove extra call.\n\tThis call was unexpected:\n\t\t%s\n\tat: %s", call.totalCalls, methodName, callString(methodName, arguments, true), assert.CallerInfo())
498498
}
499499
// we have to fail here - because we don't know what to do
500500
// as the return arguments. This is because:
@@ -514,7 +514,7 @@ func (m *Mock) MethodCalled(methodName string, arguments ...interface{}) Argumen
514514
assert.CallerInfo(),
515515
)
516516
} else {
517-
m.fail("\nassert: mock: I don't know what to return because the method call was unexpected.\n\tEither do Mock.On(%q).Return(...) first, or remove the %s() call.\n\tThis method was unexpected:\n\t\t%s\n\tat: %s", methodName, methodName, callString(methodName, arguments, true), assert.CallerInfo())
517+
m.fail("\nassert: mock: I don't know what to return because the method call was unexpected.\n\tEither do Mock.On(%#v).Return(...) first, or remove the %s() call.\n\tThis method was unexpected:\n\t\t%s\n\tat: %s", methodName, methodName, callString(methodName, arguments, true), assert.CallerInfo())
518518
}
519519
}
520520

0 commit comments

Comments
 (0)