browse: link and relink tests use paths that are absolute on Windows

This commit is contained in:
aiongg
2026-11-17 21:43:23 +00:00
parent f79937d3be
commit e388ed46c0
2 changed files with 16 additions and 9 deletions
+10 -7
View File
@@ -49,18 +49,21 @@ fn monitor(files: &Arc<Disk>, jobs: &Arc<ManualJobs>) -> LinkMonitor<u32> {
LinkMonitor::new(files.clone(), jobs.clone(), Wake::none())
}
/// Absolute on every platform: a link path that is not is refused as invalid.
const FILE: &str = if cfg!(windows) { r"C:\p\a.png" } else { "/p/a.png" };
// A file changes once: one LinkChange Ok -> Modified, and nothing on the following passes.
#[trial]
fn the_monitor_reports_a_change_once() {
let files = Disk::new(FakeLinkFiles::new().with("/p/a.png", b"abc", 1));
let a = link(1, "/p/a.png", files.identity_of("/p/a.png"));
let files = Disk::new(FakeLinkFiles::new().with(FILE, b"abc", 1));
let a = link(1, FILE, files.identity_of(FILE));
let jobs = Arc::new(ManualJobs::new());
let mut m = monitor(&files, &jobs);
m.set(&[a], None);
jobs.run_all();
assert_eq!(m.take_changes(), vec![LinkChange { key: 1, before: None, status: LinkStatus::Ok }]);
files.change(FakeLinkFiles::new().with("/p/a.png", b"abcd", 2));
files.change(FakeLinkFiles::new().with(FILE, b"abcd", 2));
m.window_focused();
jobs.run_all();
assert_eq!(m.take_changes(), vec![LinkChange { key: 1, before: Some(LinkStatus::Ok), status: LinkStatus::Modified }]);
@@ -77,10 +80,10 @@ fn the_monitor_reports_a_change_once() {
// A check that finished before the link was updated is stale when it is taken in: it reports nothing, and the newer check decides.
#[trial]
fn a_check_older_than_known_now_is_dropped() {
let files = Disk::new(FakeLinkFiles::new().with("/p/a.png", b"abc", 1));
let old = link(1, "/p/a.png", files.identity_of("/p/a.png"));
files.change(FakeLinkFiles::new().with("/p/a.png", b"abcd", 2));
let updated = link(1, "/p/a.png", files.identity_of("/p/a.png"));
let files = Disk::new(FakeLinkFiles::new().with(FILE, b"abc", 1));
let old = link(1, FILE, files.identity_of(FILE));
files.change(FakeLinkFiles::new().with(FILE, b"abcd", 2));
let updated = link(1, FILE, files.identity_of(FILE));
let jobs = Arc::new(ManualJobs::new());
let mut m = monitor(&files, &jobs);
m.set(&[old], None);
+6 -2
View File
@@ -101,11 +101,15 @@ fn linked_keys(result: &DialogResult<RelinkOutcome<u32>>) -> (Vec<u32>, Vec<u32>
(outcome.linked.iter().map(|(key, _)| *key).collect(), outcome.offline.clone())
}
/// A folder path is absolute only with a drive on Windows.
const DRIVE: &str = if cfg!(windows) { "D:" } else { "" };
#[trial]
fn relink_others_offers_the_rows_the_remap_fits() {
let files = files(&[("/T7/shoot/a.mov", SAME), ("/T7/shoot/b.mov", SAME), ("/T7/shoot/c.mov", OTHER)]);
let files =
files(&[(&format!("{DRIVE}/T7/shoot/a.mov"), SAME), (&format!("{DRIVE}/T7/shoot/b.mov"), SAME), (&format!("{DRIVE}/T7/shoot/c.mov"), OTHER)]);
let rows = vec![row(1, "Clip A", "C:\\shoot\\a.mov"), row(2, "Clip B", "C:\\shoot\\b.mov"), row(3, "Clip C", "C:\\shoot\\c.mov")];
let mut rig = rig(rows, &files, "/T7/shoot", true, true);
let mut rig = rig(rows, &files, &format!("{DRIVE}/T7/shoot"), true, true);
rig.search();
rig.click("Link");
rig.jobs.run_all();