fix(schema): report example parsing errors in TestValidateConfigExample#211
fix(schema): report example parsing errors in TestValidateConfigExample#211G26karthik wants to merge 1 commit into
Conversation
The validate() function used t.Error(err) where err was the result of extractExamples from an earlier scope. When extractExamples succeeded, err was nil, so t.Error(nil) was a no-op. This caused example parsing failures to be silently ignored rather than failing the test. Use example.Err instead so each example's actual parsing error is reported as a test failure. Signed-off-by: G26Karthik <karthik26092005@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes TestValidateConfigExample so that per-example parsing failures from docs/config.md are correctly reported and cause the test to fail, rather than being silently ignored due to logging the wrong error variable.
Changes:
- In
schema/example_test.go, reportexample.Err(the per-example parse error) instead of the earliererrvalue fromextractExamples(...).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request fixes a bug in schema/example_test.go where the incorrect variable was passed to t.Error. The reviewer recommends refactoring the error logging to use t.Errorf to avoid duplicate log entries, which would improve code conciseness and consistency.
|
Hi maintainers - flagging that the |
Fixes #210
Summary
TestValidateConfigExamplewas using the wrong error variable when reporting per-example parse failures, so example parsing errors were silently ignored instead of failing the test.Details
schema/example_test.go,example.Erris checked, butt.Error(err)is called.erris the result ofextractExamples(...)from earlier in the function and isnilonce the loop runs, sot.Error(nil)is a no-op. Any malformed example indocs/config.mdpasses the test silently.example.Errtot.Error, matching the variable that was just checked one line above. One-character variable name change, no logic change.go test ./schema -vpasses). Manually injecting a malformed example intodocs/config.mdnow correctly fails the test, where it previously passed.Testing