testify
testify copied to clipboard
Fix custom messages in comparison-assertions
Summary
This PR fixes custom messages in comparison-assertions.
Changes
The assesrtions now pass varargs rather than a single slice arg.
Motivation
The comparison-assertions were passing msgAndArgs as a slice rather than varargs, which meant that the entire message-and-arguments got printed as a single slice. Now it gets printf-ed correctly. See test cases for examples.
Edit: Fixes the rest of #1034 (the other part was fixed by #1026).
Hi @boyan-soubachov -- thanks for the look! The test I added should cover the regression, I think -- if you run it without the other changes it fails with e.g.
assertion_compare_test.go:266:
Error Trace:
Error: "\n\tError Trace:\t\n\tError: \t\"1\" is not greater than \"2\"\n\tMessages: \t[%v wasn't greater 1]\n" does not contain "1 wasn't greater"
Test: TestComparisonCustomMessages
Let me know if there was something different you wanted, I'm happy to add it!
(FYI I've also fixed the merge conflict which is from #1026.)
can we merge this? :) thanks
@boyan-soubachov PTAL
Looks like the issue was fixed in https://github.com/stretchr/testify/pull/1150/, so this PR can be closed.
@benjaminjkraft Thanks for the patch. Unfortunately it hasn't been noticed earlier.
@lambdanis Thanks for the duplicate report.