Add test coverage for nil Len() behavior#142
Conversation
The nil check in Len() was added in PR hashicorp#95 but lacked test coverage. This adds TestLenNil to verify that calling Len() on a nil *Error returns 0 instead of panicking. Fixes hashicorp#54
|
Hey @veeceey , Thanks for the contribution. This test case looks good to me but can you please resolve the failing lint CI ! |
|
Thanks for the review, @ritikrajdev! I looked into the lint failure and it's not related to my changes — the The lint job last passed on main on Jan 30 when an older golangci-lint version was in use. Since then, the latest version has moved to v2.9.0 and any new PR branch will hit this same failure. This is a pre-existing CI configuration issue — not caused by the test I added. All actual test jobs (linux and windows across Go 1.13, oldstable, and stable) pass. |
Summary
The nil check in
Len()was added in PR #95 but didn't include test coverage. This PR addsTestLenNilto verify that callingLen()on a nil*Errorreturns 0 instead of panicking.Test Results
$ go test ./... -v ... === RUN TestLenNil --- PASS: TestLenNil (0.00s) PASS ok github.com/hashicorp/go-multierror 0.243sVerified manually that nil and empty multierror both return 0:
Fixes #54