sarama
sarama copied to clipboard
Unclear documentation of returned error from MessageChecker in mocks.ExpectSendMessageWith...AndFail
Versions
Please specify real version numbers or git SHAs, not just "Latest" since that changes fairly regularly.
Sarama | Kafka | Go |
---|---|---|
v1.34.1 | n/a | 1.17.10 |
Configuration
What configuration values are you using for Sarama and Kafka? Not applicable
Logs
Not applicable
Problem Description
The documentation for mocks.ExpectSendMessageWithMessageCheckerFunctionAndFail claims that it "will cascade the error of the function, if any" where this function is the MessageChecker passed in that defines the expectation.
I understood the word "cascade" to mean "if there is an error returned from MessageChecker, the error will be wrapped in some sarama-specific way, like in a ProducerError or ProducerErrors slice, and returned to the calling code of SendMessage(s), without causing the test to fail" especially in an Expect...AndFail context. But the actual behaviour is that the error causes the test to fail by calling ErrorReporter.Errorf.
Is my expectation of this method correct? If not, then could this documentation be updated?
Thank you for taking the time to raise this issue. However, it has not had any activity on it in the past 90 days and will be closed in 30 days if no updates occur. Please check if the main branch has already resolved the issue since it was raised. If you believe the issue is still valid and you would like input from the maintainers then please comment to ask for it to be reviewed.
@nik0sc,
Looking at the code - I agree with your assessment that actual behavior is that the error will be passed to the ErrorReporter's Errorf method (most likely implemented using *testing.T). FWIW I also found the use of the word cascade
to be ambiguous.
Would revising the comment as follows make the behavior more clear?
// ExpectSendMessageWithMessageCheckerFunctionAndFail sets an expectation on the mock producer that
// SendMessage will be called. The mock producer will call the supplied MessageChecker function to check the
// message. If the checker function returns nil then the mock producer will fail the call to SendMessage with the
// error argument provided. If the checker function returns an error then it is passed to the Errorf method of the
// ErrorReporter specified when the mock was created.
Thank you for taking the time to raise this issue. However, it has not had any activity on it in the past 90 days and will be closed in 30 days if no updates occur. Please check if the main branch has already resolved the issue since it was raised. If you believe the issue is still valid and you would like input from the maintainers then please comment to ask for it to be reviewed.