Skip to content

Commit 1499620

Browse files
test: fix vacuous and weak assertions in src/sanitize.rs (#633)
1 parent 0d81e7a commit 1499620

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/sanitize.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ mod tests {
508508
fn test_enforce_byte_limit() {
509509
let big = "a".repeat(MAX_CONTENT_BYTES + 100);
510510
let result = enforce_content_limits(&big);
511-
assert!(result.len() <= MAX_CONTENT_BYTES + 100); // room for truncation notice
511+
assert!(result.len() < big.len()); // truncation must have shortened the content
512512
assert!(result.contains("[Content truncated"));
513513
}
514514

@@ -520,6 +520,8 @@ mod tests {
520520
.join("\n");
521521
let result = enforce_content_limits(&lines);
522522
assert!(result.contains("[Content truncated"));
523+
// Verify lines were actually truncated (not just the notice appended to the full input)
524+
assert!(result.lines().count() <= MAX_LINE_COUNT + 2);
523525
}
524526

525527
#[test]
@@ -553,8 +555,9 @@ mod tests {
553555
#[test]
554556
fn test_sanitize_ab_work_item_link() {
555557
let input = "This relates to AB#12345";
556-
let result = sanitize(&input);
557-
assert!(result.contains("`AB#12345`"));
558+
let result = sanitize(input);
559+
// Input has no HTML, ANSI, mentions, or unsafe protocols, so only AB# is transformed
560+
assert_eq!(result, "This relates to `AB#12345`");
558561
}
559562

560563
#[test]
@@ -583,7 +586,7 @@ mod tests {
583586
}
584587

585588
#[test]
586-
fn test_neutralize_vso_preserves_single_hash() {
589+
fn test_sanitize_preserves_markdown_headings() {
587590
let input = "# Heading\n## Sub-heading\nIssue #123";
588591
let result = sanitize(input);
589592
assert!(result.contains("# Heading"));

0 commit comments

Comments
 (0)