fix: allow mining directories without local mempalace.yaml
When no mempalace.yaml or mempal.yaml exists in the source directory, return a default config (wing = directory name, room = general) instead of calling sys.exit(1). This lets users mine any directory into their palace without requiring init first. Closes #14.
This commit is contained in:
committed by
Igor Lins e Silva
parent
4de9e135ce
commit
e8e93b53c0
+15
-1
@@ -6,7 +6,7 @@ from pathlib import Path
|
||||
import chromadb
|
||||
import yaml
|
||||
|
||||
from mempalace.miner import mine, scan_project, status
|
||||
from mempalace.miner import load_config, mine, scan_project, status
|
||||
from mempalace.palace import NORMALIZE_VERSION, file_already_mined
|
||||
|
||||
|
||||
@@ -52,6 +52,20 @@ def test_project_mining():
|
||||
shutil.rmtree(tmpdir, ignore_errors=True)
|
||||
|
||||
|
||||
def test_load_config_uses_defaults_when_yaml_missing():
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
try:
|
||||
project_root = Path(tmpdir).resolve()
|
||||
config = load_config(str(project_root))
|
||||
|
||||
assert isinstance(config, dict)
|
||||
assert "wing" in config
|
||||
assert "rooms" in config
|
||||
assert config["wing"] == project_root.name
|
||||
finally:
|
||||
shutil.rmtree(tmpdir)
|
||||
|
||||
|
||||
def test_scan_project_respects_gitignore():
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user