"""Factory test: load_backend dispatches on config.backend.type.""" from __future__ import annotations from dataclasses import dataclass from pathlib import Path import pytest from ci_orchestrator.backends import load_backend from ci_orchestrator.backends.workstation import WorkstationVmrunBackend @dataclass class _BE: type: str @dataclass class _Cfg: backend: _BE vmrun_path: str | None = None def test_load_backend_returns_workstation(tmp_path: Path) -> None: fake = tmp_path / "vmrun.exe" fake.write_bytes(b"") backend = load_backend(_Cfg(backend=_BE("workstation"), vmrun_path=str(fake))) assert isinstance(backend, WorkstationVmrunBackend) def test_load_backend_rejects_unknown(tmp_path: Path) -> None: fake = tmp_path / "vmrun.exe" fake.write_bytes(b"") with pytest.raises(NotImplementedError): load_backend(_Cfg(backend=_BE("esxi"), vmrun_path=str(fake)))