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

mock: remove unnecessary fmt.Sprintf in assert.Fail #1673

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ func (m *Mock) AssertNumberOfCalls(t TestingT, methodName string, expectedCalls
actualCalls++
}
}
return assert.Equal(t, expectedCalls, actualCalls, fmt.Sprintf("Expected number of calls (%d) does not match the actual number of calls (%d).", expectedCalls, actualCalls))
return assert.Equal(t, expectedCalls, actualCalls, "Expected number of calls (%d) does not match the actual number of calls (%d).", expectedCalls, actualCalls)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're doing this I'd also change this to assert.Equalf as we're advising people not to use the msgAndArgs variadic.

}

// AssertCalled asserts that the method was called.
Expand All @@ -679,10 +679,10 @@ func (m *Mock) AssertCalled(t TestingT, methodName string, arguments ...interfac
}
if len(calledWithArgs) == 0 {
return assert.Fail(t, "Should have called with given arguments",
fmt.Sprintf("Expected %q to have been called with:\n%v\nbut no actual calls happened", methodName, arguments))
"Expected %q to have been called with:\n%v\nbut no actual calls happened", methodName, arguments)
}
return assert.Fail(t, "Should have called with given arguments",
fmt.Sprintf("Expected %q to have been called with:\n%v\nbut actual calls were:\n %v", methodName, arguments, strings.Join(calledWithArgs, "\n")))
"Expected %q to have been called with:\n%v\nbut actual calls were:\n %v", methodName, arguments, strings.Join(calledWithArgs, "\n"))
}
return true
}
Expand All @@ -697,7 +697,7 @@ func (m *Mock) AssertNotCalled(t TestingT, methodName string, arguments ...inter
defer m.mutex.Unlock()
if m.methodWasCalled(methodName, arguments) {
return assert.Fail(t, "Should not have called with given arguments",
fmt.Sprintf("Expected %q to not have been called with:\n%v\nbut actually it was.", methodName, arguments))
"Expected %q to not have been called with:\n%v\nbut actually it was.", methodName, arguments)
}
return true
}
Expand Down