test: cover easy missing branches in report/config/credentials/ssh/wait/job
Lint / pssa (push) Successful in 34s
Lint / python (push) Successful in 41s

This commit is contained in:
2026-05-14 23:23:55 +02:00
parent b2b31f4b6e
commit dc8449a0d7
6 changed files with 371 additions and 0 deletions
+47
View File
@@ -5,6 +5,8 @@ from __future__ import annotations
import os
from pathlib import Path
import pytest
from ci_orchestrator.config import load_config
@@ -60,3 +62,48 @@ def test_env_wins_over_toml(tmp_path: Path) -> None:
env={"CI_ROOT": str(tmp_path / "fromenv")},
)
assert cfg.paths.root == tmp_path / "fromenv"
def test_ci_config_env_loads_toml(tmp_path: Path) -> None:
toml = tmp_path / "alt.toml"
toml.write_text(
f'[paths]\nroot = "{(tmp_path / "rootenv").as_posix()}"\n', encoding="utf-8"
)
cfg = load_config(env={"CI_CONFIG": str(toml)})
assert cfg.paths.root == tmp_path / "rootenv"
def test_default_config_toml_in_root_is_loaded(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""When no config_path/env is given, ``<root>/config.toml`` is autoloaded."""
import ci_orchestrator.config as cfg_mod
from ci_orchestrator.config import Paths
fake = Paths(
root=tmp_path,
templates=tmp_path / "t",
build_vms=tmp_path / "b",
artifacts=tmp_path / "a",
keys=tmp_path / "k",
)
monkeypatch.setattr(cfg_mod, "_platform_defaults", lambda: fake)
(tmp_path / "config.toml").write_text(
'[backend]\ntype = "workstation"\noption = "auto"\n', encoding="utf-8"
)
cfg = load_config(env={})
assert cfg.backend.options == {"option": "auto"}
def test_toml_provides_ssh_key_path_and_guest_cred_target(tmp_path: Path) -> None:
toml = tmp_path / "config.toml"
key = tmp_path / "id_ed25519"
key.write_text("k")
toml.write_text(
f'ssh_key_path = "{key.as_posix()}"\n'
'guest_cred_target = "MyTarget"\n',
encoding="utf-8",
)
cfg = load_config(config_path=toml, env={})
assert cfg.ssh_key_path == key
assert cfg.guest_cred_target == "MyTarget"