testify
testify copied to clipboard
assert: handle TokenTooLong error scenario
Summary
As pointed out in #1525, when the assertion message is too long, it gets completely truncated in the final output. This is because bufio.Scanner.Scan()
has a default MaxScanTokenSize
set to 65536
characters (64 * 1024). The Scan()
function returns false whenever the line being scanned exceeds that max limit. This leads to the final assertion message being truncated.
Changes
This commit fixes that by manually setting the internal scan buffer size to len(message) + 1
to make sure that the above scenario never occurs.
Related issues
Fixes #1525
@dolmen @brackendawson Can you please take one last look at this? I think it's ready to be merged
@dolmen Are we good to merge?
I'm not yet convinced that the tests provide enough coverage. I would like to see more clearly a check related to bufio boundaries.
I feel that we are testing with strings much longer than the boundary, and not just below and at the boundary. I have to dig into the code more carefully.