Expand ~ in paths
This commit is contained in:
parent
53f6cd3579
commit
9685bd533b
2 changed files with 14 additions and 1 deletions
|
|
@ -18,7 +18,7 @@ def find_config_file(cli_path: Path | None = None) -> Path | None:
|
|||
if not cli_path:
|
||||
env_path = os.getenv("HAIKU_RAG_CONFIG_PATH")
|
||||
if env_path:
|
||||
cli_path = Path(env_path)
|
||||
cli_path = Path(env_path).expanduser()
|
||||
|
||||
if cli_path:
|
||||
if cli_path.exists():
|
||||
|
|
|
|||
|
|
@ -79,6 +79,19 @@ def test_find_config_file_env_var(tmp_path, monkeypatch):
|
|||
assert found == config_file
|
||||
|
||||
|
||||
def test_find_config_file_env_var_tilde_expansion(tmp_path, monkeypatch):
|
||||
"""Test that ~ in HAIKU_RAG_CONFIG_PATH is expanded."""
|
||||
config_file = tmp_path / "from-env.yaml"
|
||||
config_file.write_text("environment: production")
|
||||
|
||||
# Point HOME to tmp_path so ~ expands there
|
||||
monkeypatch.setenv("HOME", str(tmp_path))
|
||||
monkeypatch.setenv("HAIKU_RAG_CONFIG_PATH", "~/from-env.yaml")
|
||||
|
||||
found = find_config_file()
|
||||
assert found == config_file
|
||||
|
||||
|
||||
def test_find_config_file_not_found(tmp_path, monkeypatch):
|
||||
"""Test returning None when no config found."""
|
||||
monkeypatch.delenv("HAIKU_RAG_CONFIG_PATH", raising=False)
|
||||
|
|
|
|||
Loading…
Reference in a new issue