mirror of
https://github.com/PR0M3TH3AN/Marlin.git
synced 2025-09-09 15:48:43 +00:00
Merge pull request #95 from PR0M3TH3AN/codex/fix-windows-rename-handling-in-tests
Fix path mismatch on Windows
This commit is contained in:
@@ -6,7 +6,7 @@ mod tests {
|
|||||||
use crate::backup::BackupManager;
|
use crate::backup::BackupManager;
|
||||||
// These are still from the watcher module
|
// These are still from the watcher module
|
||||||
use crate::db::open as open_marlin_db;
|
use crate::db::open as open_marlin_db;
|
||||||
use crate::utils::to_db_path;
|
use crate::utils::{canonicalize_lossy, to_db_path};
|
||||||
use crate::watcher::{FileWatcher, WatcherConfig, WatcherState}; // Use your project's DB open function
|
use crate::watcher::{FileWatcher, WatcherConfig, WatcherState}; // Use your project's DB open function
|
||||||
use crate::Marlin;
|
use crate::Marlin;
|
||||||
|
|
||||||
@@ -24,13 +24,14 @@ mod tests {
|
|||||||
expected: i64,
|
expected: i64,
|
||||||
timeout: Duration,
|
timeout: Duration,
|
||||||
) {
|
) {
|
||||||
|
let target = canonicalize_lossy(path);
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
loop {
|
loop {
|
||||||
let count: i64 = marlin
|
let count: i64 = marlin
|
||||||
.conn()
|
.conn()
|
||||||
.query_row(
|
.query_row(
|
||||||
"SELECT COUNT(*) FROM files WHERE path = ?1",
|
"SELECT COUNT(*) FROM files WHERE path = ?1",
|
||||||
[to_db_path(path)],
|
[to_db_path(&target)],
|
||||||
|r| r.get(0),
|
|r| r.get(0),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -201,6 +202,7 @@ mod tests {
|
|||||||
thread::sleep(Duration::from_millis(100));
|
thread::sleep(Duration::from_millis(100));
|
||||||
let new_file = dir.join("b.txt");
|
let new_file = dir.join("b.txt");
|
||||||
fs::rename(&file, &new_file).unwrap();
|
fs::rename(&file, &new_file).unwrap();
|
||||||
|
let new_file = canonicalize_lossy(&new_file);
|
||||||
wait_for_row_count(&marlin, &new_file, 1, Duration::from_secs(10));
|
wait_for_row_count(&marlin, &new_file, 1, Duration::from_secs(10));
|
||||||
watcher.stop().unwrap();
|
watcher.stop().unwrap();
|
||||||
assert!(
|
assert!(
|
||||||
@@ -247,6 +249,7 @@ mod tests {
|
|||||||
thread::sleep(Duration::from_millis(100));
|
thread::sleep(Duration::from_millis(100));
|
||||||
let new = dir.join("newdir");
|
let new = dir.join("newdir");
|
||||||
fs::rename(&sub, &new).unwrap();
|
fs::rename(&sub, &new).unwrap();
|
||||||
|
let new = canonicalize_lossy(&new);
|
||||||
for fname in ["one.txt", "two.txt"] {
|
for fname in ["one.txt", "two.txt"] {
|
||||||
let p = new.join(fname);
|
let p = new.join(fname);
|
||||||
wait_for_row_count(&marlin, &p, 1, Duration::from_secs(10));
|
wait_for_row_count(&marlin, &p, 1, Duration::from_secs(10));
|
||||||
|
Reference in New Issue
Block a user