test(index): update review regressions

This commit is contained in:
mikemikimike 2026-10-28 18:46:21 +08:00
parent b431ac2ffd
commit 07d601895f
No known key found for this signature in database
2 changed files with 12 additions and 4 deletions

View file

@ -1175,7 +1175,9 @@ def test_index_update_loop_retries_source_changed_during_initial_scan(monkeypatc
step: int,
poll_delay_ms: int,
stop_event: asyncio.Event,
yield_on_timeout: bool,
) -> AsyncGenerator[set[tuple[Change, str]], None]:
assert yield_on_timeout is False
del paths, watch_filter, recursive, force_polling, debounce, step, poll_delay_ms
nodes = await store.get_nodes()
watcher_contents.append(

View file

@ -17,6 +17,7 @@ from unittest.mock import patch
import pytest
from reme.components.file_chunker import DefaultFileChunker, MarkdownFileChunker
from reme.utils.file_utils import FileChangedDuringChunkingError
def _write_md(tmpdir: str, name: str, body: str) -> str:
@ -37,17 +38,22 @@ async def test_chunk_keeps_pre_read_mtime_when_source_changes(tmp_path, monkeypa
os.utime(path, (1000, 1000))
chunker = MarkdownFileChunker()
async def read_then_finish_write(_path):
original_read = chunker._read_text_for_indexing
def read_then_finish_write(_path):
path.write_text("Completed memory note.", encoding="utf-8")
os.utime(path, (2000, 2000))
return ""
monkeypatch.setattr(chunker, "_read_text_for_indexing", read_then_finish_write)
with pytest.raises(FileChangedDuringChunkingError):
await chunker.chunk("changing.md")
monkeypatch.setattr(chunker, "_read_text_for_indexing", original_read)
node, chunks = await chunker.chunk("changing.md")
assert chunks == []
assert node.st_mtime == 1000
assert path.stat().st_mtime != node.st_mtime
assert node.st_mtime == 2000
assert "Completed memory note." in "\n".join(chunk.text for chunk in chunks)
@pytest.mark.asyncio