nixos-rebuild-ng: add test to nixos-rebuild build

This commit is contained in:
Thiago Kenji Okada 2024-12-03 12:54:13 +00:00
parent debea81ba7
commit c6e9bd02ca

View File

@ -445,6 +445,35 @@ def test_execute_switch_rollback(mock_run: Any, tmp_path: Path) -> None:
)
@patch(get_qualified_name(nr.process.subprocess.run), autospec=True)
def test_execute_build(mock_run: Any, tmp_path: Path) -> None:
config_path = tmp_path / "test"
config_path.touch()
mock_run.side_effect = [
# nixos_build_flake
CompletedProcess([], 0, str(config_path)),
]
nr.execute(["nixos-rebuild", "build", "--no-flake", "--fast"])
assert mock_run.call_count == 1
mock_run.assert_has_calls(
[
call(
[
"nix-build",
"<nixpkgs/nixos>",
"--attr",
"config.system.build.toplevel",
],
check=True,
stdout=PIPE,
**DEFAULT_RUN_KWARGS,
)
]
)
@patch(get_qualified_name(nr.process.subprocess.run), autospec=True)
@patch(get_qualified_name(nr.nix.Path.exists, nr.nix), autospec=True, return_value=True)
@patch(get_qualified_name(nr.nix.Path.mkdir, nr.nix), autospec=True)