summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorПавел Жуков <33721692+LeaveMyYard@users.noreply.github.com>2023-03-28 17:47:15 +0300
committerПавел Жуков <33721692+LeaveMyYard@users.noreply.github.com>2023-03-28 17:47:15 +0300
commit76741b10493228638d6479045e179fb395af81fb (patch)
tree2b16b98877bd747e1146aec6ad438ac0d5f5f009 /tests
parentde360fcfbe0fe54f370f417fed50a7fa8663746a (diff)
Test cases, readme improvement
Diffstat (limited to 'tests')
-rw-r--r--tests/test_krr.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_krr.py b/tests/test_krr.py
new file mode 100644
index 0000000..4a25db6
--- /dev/null
+++ b/tests/test_krr.py
@@ -0,0 +1,39 @@
+"""
+ Test the krr command line interface and a general execution.
+ Requires a running kubernetes cluster with the kubectl command configured.
+"""
+
+import json
+
+import pytest
+import yaml
+from typer.testing import CliRunner
+
+from robusta_krr import app
+
+runner = CliRunner()
+
+STRATEGY_NAME = "simple"
+
+
+def test_help():
+ result = runner.invoke(app, [STRATEGY_NAME, "--help"])
+ assert result.exit_code == 0
+
+
+@pytest.mark.parametrize("log_flag", ["-v", "-q"])
+def test_run(log_flag: str):
+ result = runner.invoke(app, [STRATEGY_NAME, log_flag, "--namespace", "default"])
+ assert result.exit_code == 0
+
+
+@pytest.mark.parametrize("format", ["json", "yaml", "table", "pprint"])
+def test_output_json(format: str):
+ result = runner.invoke(app, [STRATEGY_NAME, "-q", "-f", format, "--namespace", "default"])
+ assert result.exit_code == 0
+
+ if format == "json":
+ assert json.loads(result.stdout)
+
+ if format == "yaml":
+ assert yaml.safe_load(result.stdout)