summaryrefslogtreecommitdiff
path: root/tests/test_krr.py
diff options
context:
space:
mode:
authorПавел Жуков <33721692+LeaveMyYard@users.noreply.github.com>2023-05-26 11:55:15 +0300
committerПавел Жуков <33721692+LeaveMyYard@users.noreply.github.com>2023-05-26 11:55:15 +0300
commitff3be4a24d4fdb64cd4ec0836e9917c75f964dae (patch)
tree411d55759cf7c10d0772931614927994f5e24bab /tests/test_krr.py
parent0609ae5b62947b0d55505dec23b9b4d3a5909d89 (diff)
Fix tests to work without kubeconfig
Diffstat (limited to 'tests/test_krr.py')
-rw-r--r--tests/test_krr.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/tests/test_krr.py b/tests/test_krr.py
index 23dab01..f013ee4 100644
--- a/tests/test_krr.py
+++ b/tests/test_krr.py
@@ -1,8 +1,3 @@
-"""
- Test the krr command line interface and a general execution.
- Requires a running kubernetes cluster with the kubectl command configured.
-"""
-
import json
import pytest
@@ -36,14 +31,19 @@ def test_run(log_flag: str):
@pytest.mark.parametrize("format", ["json", "yaml", "table", "pprint"])
def test_output_formats(format: str):
- result = runner.invoke(app, [STRATEGY_NAME, "-q", "-f", format, "--namespace", "default"])
+ result = runner.invoke(app, [STRATEGY_NAME, "-q", "-f", format])
try:
assert result.exit_code == 0, result.exc_info
except AssertionError as e:
raise e from result.exception
- if format == "json":
- assert json.loads(result.stdout), result.stdout
-
- if format == "yaml":
- assert yaml.safe_load(result.stdout), result.stdout
+ try:
+ if format == "json":
+ json_output = json.loads(result.stdout)
+ assert json_output, result.stdout
+ assert len(json_output["scans"]) > 0, result.stdout
+
+ if format == "yaml":
+ assert yaml.safe_load(result.stdout), result.stdout
+ except Exception as e:
+ raise Exception(result.stdout) from e