test: fix weak and near-duplicate assertions in sanitize.rs#720
Merged
Conversation
- test_sanitize_preserves_markdown_headings: replaced three weak
contains() assertions with a single assert_eq! on the full output.
The old assertion result.contains("#123") would pass even if the
implementation incorrectly wrapped bare #123 in backticks, hiding
a regression in the bot-trigger neutralization guard.
- test_sanitize_config_removes_control_chars: rewrote to use a
distinct ANSI-sequence input (val + ESC[0m + ue → value) instead
of duplicating the exact null/bell bytes already covered by
test_remove_null_and_bell. The new input exercises ANSI sequence
stripping through the config pipeline, which the old duplicate
did not uniquely verify.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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/sanitize.rsWhat was wrong
test_sanitize_preserves_markdown_headings: used three weakcontains()assertions instead of checking the full output. Critically,assert!(result.contains("#123"))would pass even if the implementation incorrectly wrapped bare#123in backticks, hiding a regression in the bot-trigger neutralization guard (which should only wrap patterns likefixes #123, not a standalone#123).test_sanitize_config_removes_control_chars: used the exact same input and expected value ("hello\x00world\x07!"→"helloworld!") as the unit testtest_remove_null_and_bell, making it a near-duplicate that adds no incremental coverage.Changes
test_sanitize_preserves_markdown_headingscontains("#123")would pass even on a wrong implementation; replaced withassert_eq!on the full outputtest_sanitize_config_removes_control_charstest_remove_null_and_bell; now uses an ANSI escape sequence input (val\x1b[0mue→value) that is distinct from the null/bell testVerification
cargo test: all 1660 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:
dev.azure.comSee Network Configuration for more information.