summaryrefslogtreecommitdiffstats
path: root/tests/cli_tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-07-17 07:34:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-07-17 07:34:44 +0000
commit02a04a2335701bfc8d6a1087338f58e9f37ceb52 (patch)
tree92c2c729cfdaaa3942a251357ff100e28a8b8624 /tests/cli_tests
parentAdding upstream version 1.9.1. (diff)
downloadiredis-02a04a2335701bfc8d6a1087338f58e9f37ceb52.tar.xz
iredis-02a04a2335701bfc8d6a1087338f58e9f37ceb52.zip
Adding upstream version 1.9.4.upstream/1.9.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/cli_tests/__init__.py0
-rw-r--r--tests/cli_tests/test_cli_start.py8
-rw-r--r--tests/cli_tests/test_command_input.py21
-rw-r--r--tests/cli_tests/test_shell_pipeline.py10
4 files changed, 38 insertions, 1 deletions
diff --git a/tests/cli_tests/__init__.py b/tests/cli_tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/cli_tests/__init__.py
diff --git a/tests/cli_tests/test_cli_start.py b/tests/cli_tests/test_cli_start.py
index d33185a..00fcbf7 100644
--- a/tests/cli_tests/test_cli_start.py
+++ b/tests/cli_tests/test_cli_start.py
@@ -10,6 +10,14 @@ def test_start_on_connection_error():
cli.close()
+def test_start_with_client_name():
+ cli = pexpect.spawn("iredis --client_name custom_name", timeout=2)
+ cli.expect("iredis")
+ cli.sendline("CLIENT GETNAME")
+ cli.expect("custom_name")
+ cli.close()
+
+
def test_short_help_option(config):
c = pexpect.spawn("iredis -h", timeout=2)
diff --git a/tests/cli_tests/test_command_input.py b/tests/cli_tests/test_command_input.py
index 4f970f5..f70ee3c 100644
--- a/tests/cli_tests/test_command_input.py
+++ b/tests/cli_tests/test_command_input.py
@@ -1,3 +1,4 @@
+import os
import pytest
@@ -8,8 +9,13 @@ def test_wrong_select_db_index(cli):
cli.sendline("select 128")
cli.expect(["DB index is out of range", "127.0.0.1:6379[1]>"])
+ if int(os.environ["REDIS_VERSION"]) > 5:
+ text = "value is not an integer or out of range"
+ else:
+ text = "invalid DB index"
+
cli.sendline("select abc")
- cli.expect(["invalid DB index", "127.0.0.1:6379[1]>"])
+ cli.expect([text, "127.0.0.1:6379[1]>"])
cli.sendline("select 15")
cli.expect("OK")
@@ -53,3 +59,16 @@ def test_auth_hidden_password(clean_redis, cli):
def test_hello_command_is_not_supported(cli):
cli.sendline("hello 3")
cli.expect("IRedis currently not support RESP3")
+
+
+def test_abort_reading_connection(cli):
+ cli.sendline("blpop mylist 30")
+ cli.send(chr(3))
+ cli.expect(
+ r"KeyboardInterrupt received! User canceled reading response!", timeout=10
+ )
+
+ cli.sendline("set foo bar")
+ cli.expect("OK")
+ cli.sendline("get foo")
+ cli.expect("bar")
diff --git a/tests/cli_tests/test_shell_pipeline.py b/tests/cli_tests/test_shell_pipeline.py
index 4bacf8d..8fe5e14 100644
--- a/tests/cli_tests/test_shell_pipeline.py
+++ b/tests/cli_tests/test_shell_pipeline.py
@@ -9,3 +9,13 @@ def test_running_disable_shell_pipeline():
cli.sendline("get foo | grep w")
cli.expect(r"hello")
cli.close()
+
+
+def test_running_disable_shell_pipeline_with_decode_option():
+ cli = pexpect.spawn("iredis -n 15 --decode=utf-8", timeout=2)
+ cli.expect("127.0.0.1")
+ cli.sendline("set foo hello")
+ cli.expect("OK")
+ cli.sendline("get foo | cat")
+ cli.expect(r"hello")
+ cli.close()