diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 03:01:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 03:01:24 +0000 |
commit | bbbba88cf6eb914c53ace70a32ed8874d5e600c2 (patch) | |
tree | 97210524cb84512c477421e1950f2c6f7e1a3089 /tests/cli_tests/test_config.py | |
parent | Initial commit. (diff) | |
download | iredis-bbbba88cf6eb914c53ace70a32ed8874d5e600c2.tar.xz iredis-bbbba88cf6eb914c53ace70a32ed8874d5e600c2.zip |
Adding upstream version 1.14.1.upstream/1.14.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/cli_tests/test_config.py')
-rw-r--r-- | tests/cli_tests/test_config.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/cli_tests/test_config.py b/tests/cli_tests/test_config.py new file mode 100644 index 0000000..eeaba33 --- /dev/null +++ b/tests/cli_tests/test_config.py @@ -0,0 +1,59 @@ +import pexpect +from textwrap import dedent +from pathlib import Path + + +def test_log_location_config(): + config_content = dedent( + """ + [main] + log_location = /tmp/iredis1.log + """ + ) + 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("127.0.0.1") + cli.close() + + log = Path("/tmp/iredis1.log") + assert log.exists() + with open(log) as logfile: + 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() |