Skip to content

Commit

Permalink
fix python tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 authored and mergify[bot] committed Dec 3, 2023
1 parent 1e77cb3 commit 25e1995
Showing 1 changed file with 28 additions and 31 deletions.
59 changes: 28 additions & 31 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from .sshd import Sshd


def cli(args: list[str]) -> None:
asyncio.run(async_main(args))
def cli(args: list[str]) -> int:
return asyncio.run(async_main(args))


def test_help() -> None:
Expand All @@ -20,39 +20,36 @@ def test_help() -> None:


def test_build() -> None:
with pytest.raises(SystemExit) as e:
cli(["--option", "builders", ""])
assert e.value.code == 1
rc = cli(["--option", "builders", ""])
assert rc == 0


def test_eval_error() -> None:
with pytest.raises(SystemExit) as e:
cli(["--option", "builders", "", "--flake", ".#legacyPackages"])
assert e.value.code == 1
rc = cli(["--option", "builders", "", "--flake", ".#legacyPackages"])
assert rc == 1


def test_remote(sshd: Sshd) -> None:
login = pwd.getpwuid(os.getuid()).pw_name
with pytest.raises(SystemExit) as e:
cli(
[
"--option",
"builders",
"",
"--remote",
f"{login}@127.0.0.1",
"--remote-ssh-option",
"Port",
str(sshd.port),
"--remote-ssh-option",
"IdentityFile",
sshd.key,
"--remote-ssh-option",
"StrictHostKeyChecking",
"no",
"--remote-ssh-option",
"UserKnownHostsFile",
"/dev/null",
]
)
assert e.value.code == 0
rc = cli(
[
"--option",
"builders",
"",
"--remote",
f"{login}@127.0.0.1",
"--remote-ssh-option",
"Port",
str(sshd.port),
"--remote-ssh-option",
"IdentityFile",
sshd.key,
"--remote-ssh-option",
"StrictHostKeyChecking",
"no",
"--remote-ssh-option",
"UserKnownHostsFile",
"/dev/null",
]
)
assert rc == 0

0 comments on commit 25e1995

Please sign in to comment.