eval-only option

This commit is contained in:
randogoth 2026-01-01 20:45:46 +02:00
parent 3969251220
commit fd7ff14ac6
3 changed files with 26 additions and 18 deletions

View file

@ -239,21 +239,24 @@ def test_env_command_eval_outputs_exports(tmp_path: Path, monkeypatch, capsys) -
"""
[variables]
EDITOR = "nvim"
OLD = "1"
""".strip()
)
env_home = tmp_path / "xdg"
env_dir = env_home / "environment.d"
env_dir.mkdir(parents=True, exist_ok=True)
env_conf = env_dir / "20-curator.conf"
env_conf.write_text("OLD=1\n")
monkeypatch.setenv("XDG_CONFIG_HOME", str(env_home))
def fake_get_paths():
return curator_dir, env_file, curator_dir / "last", curator_dir / "rollback"
def fake_apply_environment_variables(config, path, quiet=False, propagate=False):
assert quiet is True
assert propagate is True
return {"EDITOR": "nvim"}, {"OLD"}
def fail_apply_environment_variables(*_args, **_kwargs):
raise AssertionError("apply_environment_variables should not be called in eval-only mode")
monkeypatch.setattr(cli, "get_paths", fake_get_paths)
monkeypatch.setattr(cli, "apply_environment_variables", fake_apply_environment_variables)
monkeypatch.setattr(cli, "apply_environment_variables", fail_apply_environment_variables)
cli.env_command(eval_mode=True)
cli.env_command(eval_only=True)
out = capsys.readouterr().out.strip().splitlines()
assert out == ["export EDITOR=nvim", "unset OLD"]