Description
The BodyValidator (commit_check/engine.py) should be tested for edge cases involving leading blank lines and whitespace-only messages.
Note: _get_commit_message() (line 127) strips the input before it reaches BodyValidator.validate(), so leading blank lines are removed early. The following tests verify the actual behavior.
Goal
Add test cases in tests/engine_test.py under the existing TestBodyValidator class to cover:
- Message with leading blank lines and body content (e.g.
"\n\nbody content") — should FAIL (message without subject won't pass require_body)
- Message with leading blank lines and no body content (e.g.
"\n\n") — should PASS (empty after strip, treated as no commit message)
- Message with only whitespace lines (e.g.
" \n ") — should PASS (same as above)
These tests will bring coverage to 100% for the BodyValidator.validate() method.
How to verify
pytest tests/engine_test.py::TestBodyValidator -v
Coverage can be checked with:
coverage run -m pytest tests/engine_test.py::TestBodyValidator
coverage report -m
References
commit_check/engine.py — BodyValidator class (lines 530–564)
tests/engine_test.py — TestBodyValidator class (existing tests start at line 915)
Description
The
BodyValidator(commit_check/engine.py) should be tested for edge cases involving leading blank lines and whitespace-only messages.Note:
_get_commit_message()(line 127) strips the input before it reachesBodyValidator.validate(), so leading blank lines are removed early. The following tests verify the actual behavior.Goal
Add test cases in
tests/engine_test.pyunder the existingTestBodyValidatorclass to cover:"\n\nbody content") — should FAIL (message without subject won't pass require_body)"\n\n") — should PASS (empty after strip, treated as no commit message)" \n ") — should PASS (same as above)These tests will bring coverage to 100% for the
BodyValidator.validate()method.How to verify
Coverage can be checked with:
References
commit_check/engine.py—BodyValidatorclass (lines 530–564)tests/engine_test.py—TestBodyValidatorclass (existing tests start at line 915)