-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Error message on Len() assumes string #1482
Labels
Comments
@kevinburkesegment Could you submit a patch? If you submit an MR I will be able to merge it. |
dolmen
added
bug
good first issue
pkg-assert
Change related to package testify/assert
labels
Oct 11, 2023
kevinburkesegment
added a commit
to kevinburkesegment/testify
that referenced
this issue
Oct 11, 2023
Previously, the use of %s with array objects meant you would get an error like this: "[%!s(int=1) %!s(int=2) %!s(int=3)]\" should have 4 item(s), but has 3 Use %v instead, which provides a much nicer error. "[1 2 3]" should have 4 item(s), but has 3 Fixes stretchr#1482.
kevinburkesegment
added a commit
to kevinburkesegment/testify
that referenced
this issue
Oct 12, 2023
Previously, the use of %s with array objects meant you would get an error like this: "[%!s(int=1) %!s(int=2) %!s(int=3)]\" should have 4 item(s), but has 3 Use %v instead, which provides a much nicer error. "[1 2 3]" should have 4 item(s), but has 3 Fixes stretchr#1482.
kevinburkesegment
added a commit
to kevinburkesegment/testify
that referenced
this issue
Oct 12, 2023
Previously, the use of %s with array objects meant you would get an error like this: "[%!s(int=1) %!s(int=2) %!s(int=3)]\" should have 4 item(s), but has 3 Use %v instead, which provides a much nicer error. "[1 2 3]" should have 4 item(s), but has 3 Fixes stretchr#1482.
Reproducer: https://go.dev/play/p/xH-RSrn8HP6 func Test(t *testing.T) {
assert.Len(t, [...]int{1, 2, 3}, 1)
}
|
kevinburkesegment
added a commit
to kevinburkesegment/testify
that referenced
this issue
Oct 16, 2023
Previously, the use of %s with array objects meant you would get an error like this: "[%!s(int=1) %!s(int=2) %!s(int=3)]\" should have 4 item(s), but has 3 Use %v instead, which provides a much nicer error. "[1 2 3]" should have 4 item(s), but has 3 Fixes stretchr#1482.
kevinburkesegment
added a commit
to kevinburkesegment/testify
that referenced
this issue
Oct 24, 2023
Previously, the use of %s with array objects meant you would get an error like this: "[%!s(int=1) %!s(int=2) %!s(int=3)]\" should have 4 item(s), but has 3 Use %v instead, which provides a much nicer error. "[1 2 3]" should have 4 item(s), but has 3 Fixes stretchr#1482.
kevinburkesegment
added a commit
to kevinburkesegment/testify
that referenced
this issue
Oct 30, 2023
Previously, the use of %s with array objects meant you would get an error like this: "[%!s(int=1) %!s(int=2) %!s(int=3)]\" should have 4 item(s), but has 3 Use %v instead, which provides a much nicer error. "[1 2 3]" should have 4 item(s), but has 3 Fixes stretchr#1482.
kevinburkesegment
added a commit
to kevinburkesegment/testify
that referenced
this issue
Oct 31, 2023
Previously, the use of %s with array objects meant you would get an error like this: "[%!s(int=1) %!s(int=2) %!s(int=3)]\" should have 4 item(s), but has 3 Use %v instead, which provides a much nicer error. "[1 2 3]" should have 4 item(s), but has 3 Fixes stretchr#1482.
kevinburkesegment
added a commit
to kevinburkesegment/testify
that referenced
this issue
Feb 15, 2024
Previously, the use of %s with array objects meant you would get an error like this: "[%!s(int=1) %!s(int=2) %!s(int=3)]\" should have 4 item(s), but has 3 Use %v instead, which provides a much nicer error. "[1 2 3]" should have 4 item(s), but has 3 Fixes stretchr#1482.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This error message in
assert.Len
assumes that whatever you are asserting a length about can be formatted with the%s
format string.If you look at the failure in e.g. https://drone.grafana.net/grafana/dskit/3189/1/4, I believe this is a []uint32, which is being formatted as
"[%!s(uint32=2452015680) %!s(uint32=2476020736)]"
.I think the
%v
format string might be a better fit.The text was updated successfully, but these errors were encountered: