summaryrefslogtreecommitdiffstats
path: root/tests/cli_tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-08-15 12:04:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-08-15 12:04:47 +0000
commit69829819561dd586ad38aeb10ed71ca0771b9d7a (patch)
treed0e1796fcbc62101389684c576dd4fe282b88715 /tests/cli_tests
parentReleasing debian version 1.12.0-1. (diff)
downloadiredis-69829819561dd586ad38aeb10ed71ca0771b9d7a.tar.xz
iredis-69829819561dd586ad38aeb10ed71ca0771b9d7a.zip
Merging upstream version 1.12.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/cli_tests')
-rw-r--r--tests/cli_tests/test_cli_start.py8
-rw-r--r--tests/cli_tests/test_config.py34
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/cli_tests/test_cli_start.py b/tests/cli_tests/test_cli_start.py
index 00fcbf7..8045947 100644
--- a/tests/cli_tests/test_cli_start.py
+++ b/tests/cli_tests/test_cli_start.py
@@ -81,3 +81,11 @@ def test_connect_via_socket(fake_redis_socket):
c.expect("redis /tmp/test.sock")
c.close()
+
+
+def test_iredis_start_with_prompt():
+ cli = pexpect.spawn("iredis --prompt '{host}abc{port}def{client_name}'", timeout=2)
+ cli.logfile_read = open("cli_test.log", "ab")
+ cli.expect("iredis")
+ cli.expect("127.0.0.1abc6379defNone")
+ cli.close()
diff --git a/tests/cli_tests/test_config.py b/tests/cli_tests/test_config.py
index 7d6839d..1795c62 100644
--- a/tests/cli_tests/test_config.py
+++ b/tests/cli_tests/test_config.py
@@ -23,3 +23,37 @@ def test_log_location_config():
content = logfile.read()
assert len(content) > 100
+
+
+def test_load_prompt_from_config(iredis_client, clean_redis):
+ config_content = dedent(
+ """
+ [main]
+ prompt = {host}abc{port}xx{db}
+ """
+ )
+ with open("/tmp/iredisrc", "w+") as etc_config:
+ etc_config.write(config_content)
+
+ cli = pexpect.spawn("iredis -n 15 --iredisrc /tmp/iredisrc", timeout=1)
+ cli.expect("iredis")
+ cli.expect("127.0.0.1abc6379xx15")
+ cli.close()
+
+
+def test_prompt_cli_overwrite_config(iredis_client, clean_redis):
+ config_content = dedent(
+ """
+ [main]
+ prompt = {host}abc{port}xx{db}
+ """
+ )
+ with open("/tmp/iredisrc", "w+") as etc_config:
+ etc_config.write(config_content)
+
+ cli = pexpect.spawn(
+ "iredis -n 15 --iredisrc /tmp/iredisrc --prompt='{db}-12345'", timeout=1
+ )
+ cli.expect("iredis")
+ cli.expect("15-12345")
+ cli.close()