From bbb496ffdea8d94650036cdc310a96044aae0004 Mon Sep 17 00:00:00 2001 From: MrTrustworthy Date: Fri, 6 Sep 2019 10:10:27 +0200 Subject: [PATCH] regression test (#42) --- tests/integration/test_topic_controller.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/integration/test_topic_controller.py b/tests/integration/test_topic_controller.py index 88a9c8af..ac0b2479 100644 --- a/tests/integration/test_topic_controller.py +++ b/tests/integration/test_topic_controller.py @@ -210,6 +210,24 @@ def test_apply_duplicate_names(topic_controller: TopicController, topic_id: str) assert result.exit_code != 0 and isinstance(result.exception, ValueError), f"Calling apply should have failed" +@pytest.mark.integration +def test_apply_invalid_replicas(topic_controller: TopicController, topic_id: str): + runner = CliRunner() + topic_name = f"apply_{topic_id}" + topic_1 = { + "name": topic_name, + "replication_factor": 100, + "num_partitions": 50, + "config": {"cleanup.policy": "compact"}, + } + apply_conf = {"topics": [topic_1]} + + # having the same topic name twice in apply should raise an ValueError + path = save_yaml(topic_id, apply_conf) + result = runner.invoke(apply, ["-f", path], input="Y\n") + assert result.exit_code != 0 and isinstance(result.exception, KafkaException), f"Calling apply should have failed" + + def save_yaml(fname: str, data: Dict[str, Any]) -> str: # this path name is in the gitignore so the temp files are not committed path = f"tests/test_samples/{fname}_apply.yaml"