Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions src-tauri/src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,55 @@ mod tests {
snap.disk_app_bytes
);
}

#[test]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Ergänze einen tatsächlich erkannten No-Test-Trailer

Sobald dieser Commit durch den red-first-Check läuft, wird er abgelehnt: src-tauri/src/resources.rs gilt gemäß tf_path_is_source in scripts/lib/test-first.sh:27-37 als trailerpflichtiger Quellcode, aber die Commitnachricht enthält nur den Aufzählungspunkt - Trailer: No-Test (...); tf_message_has_required_trailer akzeptiert in Zeile 56 ausschließlich eine Zeile, die direkt mit No-Test:, Test-First: oder Regression-For: beginnt, sodass scripts/ci/red-first.sh:148-153 mit Fehler beendet. Die Commitnachricht benötigt daher eine eigenständige Zeile wie No-Test: test-only coverage additions.

AGENTS.md reference: AGENTS.md:L155-L158

Useful? React with 👍 / 👎.

fn dir_size_sums_nested_files() {
let dir = TempDir::new("resource-nested");
std::fs::create_dir_all(dir.path().join("a/b")).unwrap();
std::fs::write(dir.path().join("top.bin"), vec![0u8; 10]).unwrap();
std::fs::write(dir.path().join("a/mid.bin"), vec![0u8; 20]).unwrap();
std::fs::write(dir.path().join("a/b/deep.bin"), vec![0u8; 30]).unwrap();
assert_eq!(dir_size(dir.path()), Some(60));
}

#[test]
fn dir_size_of_empty_dir_is_zero_and_of_missing_path_is_none() {
let dir = TempDir::new("resource-empty");
assert_eq!(dir_size(dir.path()), Some(0));
// Missing data is honest: None, not a fake zero.
assert_eq!(dir_size(&dir.path().join("does-not-exist")), None);
}

#[cfg(unix)]
#[test]
fn dir_size_does_not_follow_symlinks() {
let outside = TempDir::new("resource-outside");
std::fs::write(outside.path().join("big.bin"), vec![0u8; 4096]).unwrap();
let dir = TempDir::new("resource-link");
std::fs::write(dir.path().join("own.bin"), vec![0u8; 5]).unwrap();
std::os::unix::fs::symlink(outside.path(), dir.path().join("dir-link")).unwrap();
std::os::unix::fs::symlink(outside.path().join("big.bin"), dir.path().join("file-link"))
.unwrap();
assert_eq!(dir_size(dir.path()), Some(5));
}

#[cfg(target_os = "linux")]
#[test]
fn linux_probes_report_plausible_memory_figures() {
let total = system_ram_bytes().expect("MemTotal");
let process = process_ram_bytes().expect("statm");
assert!(total > 0);
assert!(process > 0 && process < total, "{process} vs {total}");
}

#[test]
fn snapshot_of_missing_app_data_keeps_tokens_and_reports_no_size() {
let dir = TempDir::new("resource-missing");
let snap = snapshot(&dir.path().join("gone"), -1, 7, 42);
assert_eq!(snap.disk_app_bytes, None);
assert_eq!(
(snap.tokens_in, snap.tokens_out, snap.observed_at),
(-1, 7, 42)
);
}
}
Loading