testing/slogtest: TestHandler passing tests that should fail #67605
Labels
FixPending
Issues that have a fix which has not yet been reviewed or submitted.
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
Go version
go version go1.22.0 linux/amd64
Output of
go env
in your module/workspace:What did you do?
I was trying to implement slog test handlers based off of the example code. But when checking for the expected errors with parsing empty maps, it still passes the test.
Here is the go playground of the error (or lack of)
It looks like in the source code at line 219 it calls the test again without checking for the length of the returned slice. So when a 0 length slice is returned the tests aren't run.
There is a workaround where you put the results back into the channel, but that is easy to overloook. workaround go playground
The code should be updated to check for the lengths again, or use the results from the length checking test call.
What did you see happen?
Ran the test and got this response.
What did you expect to see?
Expected to get a list of missing keys in the returned maps.
test errors: A lot of errors for each map key
The text was updated successfully, but these errors were encountered: