diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-03-21 10:28:17 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-02-07 11:16:53 +0000 |
commit | 06cba6ccd165ca8b224797e37fccb9e63f026d77 (patch) | |
tree | e82f1bc439997ae296f2e74f8a64d84c5d95f140 /tests/cli_tests/test_cli_start.py | |
parent | Initial commit. (diff) | |
download | iredis-06cba6ccd165ca8b224797e37fccb9e63f026d77.tar.xz iredis-06cba6ccd165ca8b224797e37fccb9e63f026d77.zip |
Adding upstream version 1.9.1.upstream/1.9.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/cli_tests/test_cli_start.py')
-rw-r--r-- | tests/cli_tests/test_cli_start.py | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/cli_tests/test_cli_start.py b/tests/cli_tests/test_cli_start.py new file mode 100644 index 0000000..d33185a --- /dev/null +++ b/tests/cli_tests/test_cli_start.py @@ -0,0 +1,75 @@ +import pexpect +import pytest +from textwrap import dedent + + +def test_start_on_connection_error(): + cli = pexpect.spawn("iredis -p 12345", timeout=1) + cli.logfile_read = open("cli_test.log", "ab") + cli.expect(r"Error \d+ connecting to 127.0.0.1:12345. Connection refused.") + cli.close() + + +def test_short_help_option(config): + c = pexpect.spawn("iredis -h", timeout=2) + + c.expect("Show this message and exit.") + + c = pexpect.spawn("iredis -h 127.0.0.1") + c.expect("127.0.0.1:6379>") + + c.close() + + +@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) != 5") +def test_server_version_in_starting_on5(): + c = pexpect.spawn("iredis", timeout=2) + c.expect("redis-server 5") + c.close() + + +@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) != 6") +def test_server_version_in_starting_on6(): + c = pexpect.spawn("iredis", timeout=2) + c.expect("redis-server 6") + c.close() + + +def test_connection_using_url(clean_redis): + c = pexpect.spawn("iredis --url redis://localhost:6379/7", timeout=2) + c.logfile_read = open("cli_test.log", "ab") + c.expect(["iredis", "127.0.0.1:6379[7]>"]) + c.sendline("set current-db 7") + c.expect("OK") + c.close() + + +def test_connection_using_url_from_env(clean_redis, monkeypatch): + monkeypatch.setenv("IREDIS_URL", "redis://localhost:6379/7") + c = pexpect.spawn("iredis", timeout=2) + c.logfile_read = open("cli_test.log", "ab") + c.expect(["iredis", "localhost:6379[7]>"]) + c.sendline("set current-db 7") + c.expect("OK") + c.close() + + +@pytest.mark.xfail(reason="current test in github action, socket not supported.") +# https://github.community/t5/GitHub-Actions/Job-service-command/td-p/33901# +# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idservices +def test_connect_via_socket(fake_redis_socket): + config_content = dedent( + """ + [main] + log_location = /tmp/iredis1.log + no_info=True + """ + ) + with open("/tmp/iredisrc", "w+") as etc_config: + etc_config.write(config_content) + + c = pexpect.spawn("iredis --iredisrc /tmp/iredisrc -s /tmp/test.sock", timeout=2) + c.logfile_read = open("cli_test.log", "ab") + c.expect("redis /tmp/test.sock") + + c.close() |