chore: implement rdb init project structure
This commit is contained in:
+29
-1
@@ -1,6 +1,6 @@
|
||||
from pathlib import Path
|
||||
|
||||
from rdb_discovery.templates import write_file_if_missing
|
||||
from rdb_discovery.templates import CONTEXT_FILES, write_file_if_missing
|
||||
|
||||
|
||||
def test_write_file_if_missing(tmp_path: Path) -> None:
|
||||
@@ -8,3 +8,31 @@ def test_write_file_if_missing(tmp_path: Path) -> None:
|
||||
assert (tmp_path / "context" / "test.md").read_text(encoding="utf-8") == "hello"
|
||||
assert write_file_if_missing(tmp_path, "context/test.md", "changed") is False
|
||||
assert (tmp_path / "context" / "test.md").read_text(encoding="utf-8") == "hello"
|
||||
|
||||
|
||||
def test_all_context_files_have_content() -> None:
|
||||
for path, content in CONTEXT_FILES.items():
|
||||
assert content.strip(), f"Empty content for {path}"
|
||||
|
||||
|
||||
def test_init_creates_all_files(tmp_path: Path) -> None:
|
||||
for relative_path, content in CONTEXT_FILES.items():
|
||||
write_file_if_missing(tmp_path, relative_path, content)
|
||||
|
||||
for relative_path in CONTEXT_FILES:
|
||||
assert (tmp_path / relative_path).exists(), f"Missing {relative_path}"
|
||||
|
||||
|
||||
def test_init_skips_existing_files(tmp_path: Path) -> None:
|
||||
skipped = []
|
||||
|
||||
for relative_path, content in CONTEXT_FILES.items():
|
||||
target = tmp_path / relative_path
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
target.write_text("existing", encoding="utf-8")
|
||||
result = write_file_if_missing(tmp_path, relative_path, content)
|
||||
if not result:
|
||||
skipped.append(relative_path)
|
||||
|
||||
assert skipped == list(CONTEXT_FILES)
|
||||
assert (tmp_path / "TASKS.md").read_text(encoding="utf-8") == "existing"
|
||||
|
||||
Reference in New Issue
Block a user