Skip to content

Commit 37482a2

Browse files
Fixed exit code related integration tests (#625)
1 parent a76d254 commit 37482a2

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

tests/integration/cli/test_host_overrides.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
from pytest import MonkeyPatch
44

5+
from linodecli.exit_codes import ExitCodes
56
from tests.integration.helpers import INVALID_HOST, exec_failing_test_command
67

78

89
def test_cli_command_fails_to_access_invalid_host(monkeypatch: MonkeyPatch):
910
monkeypatch.setenv("LINODE_CLI_API_HOST", INVALID_HOST)
1011

11-
process = exec_failing_test_command(["linode-cli", "linodes", "ls"])
12+
process = exec_failing_test_command(
13+
["linode-cli", "linodes", "ls"], ExitCodes.UNRECOGNIZED_COMMAND
14+
)
1215
output = process.stderr.decode()
1316

1417
expected_output = ["Max retries exceeded with url:", "wrongapi.linode.com"]
@@ -29,7 +32,9 @@ def test_cli_command_fails_to_access_invalid_api_scheme(
2932
monkeypatch: MonkeyPatch,
3033
):
3134
monkeypatch.setenv("LINODE_CLI_API_SCHEME", "ssh")
32-
process = exec_failing_test_command(["linode-cli", "linodes", "ls"])
35+
process = exec_failing_test_command(
36+
["linode-cli", "linodes", "ls"], ExitCodes.UNRECOGNIZED_COMMAND
37+
)
3338
output = process.stderr.decode()
3439

3540
assert "ssh://" in output

tests/integration/helpers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from string import ascii_lowercase
55
from typing import Callable, List
66

7+
from linodecli.exit_codes import ExitCodes
8+
79
BASE_URL = "https://api.linode.com/v4/"
810
INVALID_HOST = "https://wrongapi.linode.com"
911
SUCCESS_STATUS_CODE = 0
@@ -34,7 +36,9 @@ def exec_test_command(args: List[str]):
3436
return process
3537

3638

37-
def exec_failing_test_command(args: List[str], expected_code: int = 1):
39+
def exec_failing_test_command(
40+
args: List[str], expected_code: int = ExitCodes.REQUEST_FAILED
41+
):
3842
process = subprocess.run(args, stderr=subprocess.PIPE)
3943
assert process.returncode == expected_code
4044
return process

tests/integration/image/test_plugin_image_upload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_invalid_file(
5757
)
5858
output = process.stdout.decode()
5959

60-
assert process.returncode == 2
60+
assert process.returncode == 8
6161
assert f"No file at {file_path}" in output
6262

6363

0 commit comments

Comments
 (0)