fix: tighten stress_rename_operations assertion to check relevant paths

Bugbot flagged `has_create || has_remove || !events.is_empty()` as
trivially true. Replace with a check that at least one event references
either the original or renamed path, regardless of event type (FSEvents
on macOS reports renames as Write/Metadata, not always Create/Remove).
This commit is contained in:
Joe 2026-03-12 20:27:08 -05:00
parent 22808e6140
commit 361b4a30ec

View file

@ -866,17 +866,18 @@ mod tests {
// Should get either:
// - Remove(original) + Create(renamed) for RenameMode::Both
// - Or separate From/To events
let has_remove = events
.iter()
.any(|e| matches!(e, VfsEvent::Remove(p) if p == &original));
let has_create = events
.iter()
.any(|e| matches!(e, VfsEvent::Create(p) if p == &renamed));
// FSEvents on macOS may report renames as Write/Metadata events rather
// than the specific Create/Remove pair. Verify that at least one event
// references either the original or renamed path.
let has_relevant_event = events.iter().any(|e| match e {
VfsEvent::Create(p) | VfsEvent::Write(p) | VfsEvent::Remove(p) => {
p == &original || p == &renamed
}
});
// At minimum we should see the new file appear
assert!(
has_create || has_remove || !events.is_empty(),
"Expected rename to generate events (got {} events: {:?})",
has_relevant_event,
"Expected rename to generate events for original or renamed path (got {} events: {:?})",
events.len(),
events
);