Skip to content

Commit 36149d6

Browse files
committed
fix: improve force_full test to set mtime before watermark
The test was failing in CI because restoring the original mtime still resulted in a time newer than the watermark. Now we explicitly set the mtime to 10 seconds before the watermark to ensure the incremental scan won't detect the change, properly testing that force_full bypasses the watermark optimization. Issue #407 Signed-off-by: phernandez <paul@basicmachines.co>
1 parent 895a799 commit 36149d6

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

tests/sync/test_sync_service_incremental.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,21 @@ async def test_force_full_bypasses_watermark_optimization(
177177
await sleep_past_watermark()
178178

179179
# Modify a file WITHOUT updating mtime (simulates external tool like rclone)
180-
# We do this by reading the current mtime, modifying the file, then restoring the mtime
180+
# We set mtime to be BEFORE the watermark to ensure incremental scan won't detect it
181181
file_path = project_dir / "file1.md"
182182
original_stat = file_path.stat()
183183
await create_test_file(file_path, "# File 1\nModified by external tool")
184-
# Restore original mtime to simulate external tool behavior
185-
import os
186184

187-
os.utime(file_path, (original_stat.st_atime, original_stat.st_mtime))
185+
# Set mtime to be before the watermark (use time from before first sync)
186+
# This simulates rclone bisync which may preserve original timestamps
187+
import os
188+
old_time = initial_timestamp - 10 # 10 seconds before watermark
189+
os.utime(file_path, (old_time, old_time))
188190

189-
# Normal incremental sync should NOT detect the change (mtime unchanged)
191+
# Normal incremental sync should NOT detect the change (mtime before watermark)
190192
report = await sync_service.sync(project_dir)
191193
assert len(report.modified) == 0, (
192-
"Incremental scan should not detect changes with unchanged mtime"
194+
"Incremental scan should not detect changes with mtime older than watermark"
193195
)
194196

195197
# Force full scan should detect the change via checksum comparison

0 commit comments

Comments
 (0)