generated from coulomb/repo-seed
Optional JSONPath query/extract support, FTS5 section/block search, mkt cache query and search. Local SQLite backend now supports parsed snapshot persistence, incremental refresh, cached querying, and ranked full-text search
This commit is contained in:
@@ -57,6 +57,23 @@ def test_local_snapshot_store_deletes_removed_files(tmp_path: Path):
|
||||
assert store.load_state() == []
|
||||
|
||||
|
||||
def test_local_snapshot_store_searches_sections_and_blocks(tmp_path: Path):
|
||||
source = tmp_path / "doc.md"
|
||||
source.write_text(
|
||||
"# Doc\n\n## Decision\n\nWe choose a local SQLite index for repeated queries.\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
store = LocalSnapshotStore(local_index_path_for(tmp_path))
|
||||
store.build([tmp_path], root=tmp_path)
|
||||
|
||||
results = store.search("SQLite")
|
||||
|
||||
assert results
|
||||
assert results[0].path == "doc.md"
|
||||
assert {result.unit_kind for result in results} <= {"section", "block"}
|
||||
assert any("SQLite index" in result.text for result in results)
|
||||
|
||||
|
||||
def test_mkt_ast_show_and_stats(tmp_path: Path):
|
||||
source = tmp_path / "doc.md"
|
||||
source.write_text("# Doc\n\nBody.\n", encoding="utf-8")
|
||||
@@ -87,3 +104,44 @@ def test_mkt_cache_init_and_index(tmp_path: Path):
|
||||
assert "parsed: 1" in indexed.output
|
||||
assert clean.exit_code == 0
|
||||
assert "clean" in clean.output
|
||||
|
||||
|
||||
def test_mkt_search_uses_local_index(tmp_path: Path):
|
||||
source = tmp_path / "doc.md"
|
||||
source.write_text("# Doc\n\nSearchable local index content.\n", encoding="utf-8")
|
||||
runner = CliRunner()
|
||||
indexed = runner.invoke(main, ["cache", "index", str(tmp_path), "--root", str(tmp_path)])
|
||||
|
||||
result = runner.invoke(main, ["search", "Searchable", "--root", str(tmp_path)])
|
||||
|
||||
assert indexed.exit_code == 0
|
||||
assert result.exit_code == 0
|
||||
assert "match(es)" in result.output
|
||||
assert "doc.md" in result.output
|
||||
|
||||
|
||||
def test_mkt_cache_query_uses_indexed_snapshots(tmp_path: Path):
|
||||
one = tmp_path / "one.md"
|
||||
two = tmp_path / "two.md"
|
||||
one.write_text("# One\n\n## Decision\n\nUse SQLite.\n", encoding="utf-8")
|
||||
two.write_text("# Two\n\n## Context\n\nOther material.\n", encoding="utf-8")
|
||||
runner = CliRunner()
|
||||
indexed = runner.invoke(main, ["cache", "index", str(tmp_path), "--root", str(tmp_path)])
|
||||
|
||||
result = runner.invoke(
|
||||
main,
|
||||
[
|
||||
"cache",
|
||||
"query",
|
||||
"sections[heading=Decision]",
|
||||
"--root",
|
||||
str(tmp_path),
|
||||
"--format",
|
||||
"json",
|
||||
],
|
||||
)
|
||||
|
||||
assert indexed.exit_code == 0
|
||||
assert result.exit_code == 0
|
||||
assert '"count": 1' in result.output
|
||||
assert '"source_path": "one.md"' in result.output
|
||||
|
||||
Reference in New Issue
Block a user