test: fix vacuous is_err() assertions in add_pr_comment and update_pr#1574
Merged
jamesadevine merged 1 commit intoJul 21, 2026
Conversation
Strengthen 5 validation rejection tests that previously only checked is_err() without verifying the error message content. A silent change to the validation logic (e.g. wrong field guarded, wrong error path reached) would have let these tests pass unnoticed. - add_pr_comment::test_validation_rejects_zero_pr_id - add_pr_comment::test_validation_rejects_short_content - add_pr_comment::test_validation_rejects_repository_pipeline_command - add_pr_comment::test_validation_rejects_line_without_file_path - update_pr::test_validation_rejects_invalid_operation Each test now calls unwrap_err() and asserts the error string contains the key phrase that identifies the guard that fired. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jamesadevine
marked this pull request as ready for review
July 21, 2026 13:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test Suite Reduction:
src/safe_outputs/add_pr_comment.rs+src/safe_outputs/update_pr.rsWhat was wrong
Five validation-rejection tests used bare
is_err()without inspecting the error message. A silent change to the validation logic — e.g. the wrong field being checked, or a different code path reaching the error return — would have let these tests pass while the feature regressed unnoticed.add_pr_comment::test_validation_rejects_zero_pr_idassert!(result.is_err())— doesn't verify the guard that firedadd_pr_comment::test_validation_rejects_short_contentassert!(result.is_err())— doesn't verify the content-length messageadd_pr_comment::test_validation_rejects_repository_pipeline_commandassert!(result.is_err())— doesn't verify the injection-detection messageadd_pr_comment::test_validation_rejects_line_without_file_pathassert!(result.is_err())— doesn't verify the cross-field constraint messageupdate_pr::test_validation_rejects_invalid_operationassert!(result.is_err())— doesn't verify the allowed-operations messageChanges
Each test now calls
unwrap_err().to_string()and asserts the error string contains the key phrase that identifies which guard fired:test_validation_rejects_zero_pr_id"pull_request_id must be positive"test_validation_rejects_short_content"content must be at least 10 characters"test_validation_rejects_repository_pipeline_command"pipeline command"test_validation_rejects_line_without_file_path"line requires file_path"test_validation_rejects_invalid_operation"operation must be one of"Verification
cargo test: all tests pass ✅cargo clippy --all-targets --all-features: no errors ✅Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
spsprodeus21.vssps.visualstudio.comSee Network Configuration for more information.