test: add pytest coverage for plugin utilities

This commit is contained in:
scawful
2025-12-30 13:21:56 -05:00
parent 85b16363f5
commit 3de9c302ce
6 changed files with 102 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
from __future__ import annotations
from pathlib import Path
from afs_scawful.resource_index import ResourceIndexer
def test_resource_indexer_dedupes(tmp_path: Path) -> None:
root = tmp_path / "resources"
root.mkdir()
(root / "a.txt").write_text("same\n", encoding="utf-8")
(root / "b.txt").write_text("same\n", encoding="utf-8")
(root / "c.md").write_text("diff\n", encoding="utf-8")
indexer = ResourceIndexer(
resource_roots=[root],
search_patterns=["**/*.txt", "**/*.md"],
exclude_patterns=[],
index_path=tmp_path / "index.json",
)
result = indexer.build_index()
assert result.total_files == 2
assert result.duplicates_found == 1
assert result.by_type.get("txt", 0) == 1
assert result.by_type.get("md", 0) == 1