Adding upstream version 1.14.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
9e8d2d0c6a
commit
1ff56e1f8f
19 changed files with 152 additions and 114 deletions
|
@ -1,6 +1,8 @@
|
|||
from textwrap import dedent
|
||||
|
||||
from packaging.version import parse as version_parse # noqa: F401
|
||||
import pexpect
|
||||
import pytest
|
||||
from textwrap import dedent
|
||||
|
||||
|
||||
def test_start_on_connection_error():
|
||||
|
@ -29,14 +31,14 @@ def test_short_help_option(config):
|
|||
c.close()
|
||||
|
||||
|
||||
@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) != 5")
|
||||
@pytest.mark.skipif("version_parse(os.environ['REDIS_VERSION']) != version_parse('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")
|
||||
@pytest.mark.skipif("version_parse(os.environ['REDIS_VERSION']) != version_parse('6')")
|
||||
def test_server_version_in_starting_on6():
|
||||
c = pexpect.spawn("iredis", timeout=2)
|
||||
c.expect("redis-server 6")
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import os
|
||||
|
||||
from packaging.version import parse as version_parse
|
||||
import pytest
|
||||
|
||||
|
||||
|
@ -9,7 +11,7 @@ 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:
|
||||
if version_parse(os.environ["REDIS_VERSION"]) > version_parse("5"):
|
||||
text = "value is not an integer or out of range"
|
||||
else:
|
||||
text = "invalid DB index"
|
||||
|
@ -42,14 +44,14 @@ def test_enter_key_binding(clean_redis, cli):
|
|||
cli.expect(r"hello")
|
||||
|
||||
|
||||
@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) < 6")
|
||||
@pytest.mark.skipif("version_parse(os.environ['REDIS_VERSION']) < version_parse('6')")
|
||||
def test_auth_hidden_password_with_username(clean_redis, cli):
|
||||
cli.send("auth default hello-world")
|
||||
cli.expect("default")
|
||||
cli.expect(r"\*{11}")
|
||||
|
||||
|
||||
@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) > 5")
|
||||
@pytest.mark.skipif("version_parse(os.environ['REDIS_VERSION']) > version_parse('5')")
|
||||
def test_auth_hidden_password(clean_redis, cli):
|
||||
cli.send("auth hello-world")
|
||||
cli.expect("auth")
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from packaging.version import parse as version_parse # noqa: F401
|
||||
import pytest
|
||||
|
||||
|
||||
|
@ -37,7 +38,7 @@ def test_command_completion_when_space_command(cli, clean_redis):
|
|||
cli.expect("command info")
|
||||
|
||||
|
||||
@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) < 6")
|
||||
@pytest.mark.skipif("version_parse(os.environ['REDIS_VERSION']) < version_parse('6')")
|
||||
def test_username_completer(cli, iredis_client):
|
||||
iredis_client.execute("acl setuser", "foo1")
|
||||
iredis_client.execute("acl setuser", "bar2")
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
# noqa: F541
|
||||
import os
|
||||
import sys
|
||||
import pexpect
|
||||
import pathlib
|
||||
from contextlib import contextmanager
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
from textwrap import dedent
|
||||
from packaging.version import parse as version_parse
|
||||
|
||||
import pexpect
|
||||
|
||||
|
||||
TEST_IREDISRC = "/tmp/.iredisrc.test"
|
||||
|
@ -22,6 +24,10 @@ env_pager_numbers = "{0} {1} {2}".format(
|
|||
TEST_PAGER_BOUNDARY_NUMBER,
|
||||
)
|
||||
|
||||
long_list_type = "quicklist"
|
||||
if version_parse(os.environ["REDIS_VERSION"]) >= version_parse("7"):
|
||||
long_list_type = "listpack"
|
||||
|
||||
|
||||
@contextmanager
|
||||
def pager_enabled_cli():
|
||||
|
@ -54,11 +60,6 @@ def test_using_pager_works_for_help():
|
|||
child.expect(TEST_PAGER_BOUNDARY)
|
||||
|
||||
|
||||
long_list_type = "quicklist"
|
||||
if os.environ["REDIS_VERSION"] == "7":
|
||||
long_list_type = "listpack"
|
||||
|
||||
|
||||
def test_pager_works_for_peek(clean_redis):
|
||||
for index in range(100):
|
||||
clean_redis.lpush("long-list", f"value-{index}")
|
||||
|
|
|
@ -105,7 +105,7 @@ def cli():
|
|||
|
||||
child = pexpect.spawn(f"iredis -n 15 --iredisrc {f.name}", timeout=TIMEOUT, env=env)
|
||||
child.logfile_read = open("cli_test.log", "ab")
|
||||
child.expect(["https://iredis.io/issues", "127.0.0.1"])
|
||||
child.expect(["https://github.com/laixintao/iredis/issues", "127.0.0.1"])
|
||||
yield child
|
||||
child.close()
|
||||
|
||||
|
@ -129,7 +129,7 @@ def raw_cli():
|
|||
f"iredis --raw -n 15 --iredisrc {TEST_IREDISRC}", timeout=TIMEOUT
|
||||
)
|
||||
child.logfile_read = open("cli_test.log", "ab")
|
||||
child.expect(["https://iredis.io/issues", "127.0.0.1"])
|
||||
child.expect(["https://github.com/laixintao/iredis/issues", "127.0.0.1"])
|
||||
yield child
|
||||
child.close()
|
||||
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
import os
|
||||
import re
|
||||
from textwrap import dedent
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from packaging.version import parse as version_parse
|
||||
from prompt_toolkit.formatted_text import FormattedText
|
||||
import pytest
|
||||
import redis
|
||||
from unittest.mock import MagicMock, patch
|
||||
from textwrap import dedent
|
||||
|
||||
from prompt_toolkit.formatted_text import FormattedText
|
||||
|
||||
from iredis.client import Client
|
||||
from iredis.config import config, load_config_files
|
||||
from iredis.commands import command2syntax
|
||||
from iredis.completers import IRedisCompleter
|
||||
from iredis.config import config, load_config_files
|
||||
from iredis.entry import Rainbow, prompt_message
|
||||
from iredis.exceptions import NotSupport
|
||||
from iredis.commands import command2syntax
|
||||
|
||||
from ..helpers import formatted_text_rematch
|
||||
|
||||
|
||||
|
@ -24,7 +26,7 @@ def completer():
|
|||
zset_type = "ziplist"
|
||||
hash_type = "hashtable"
|
||||
list_type = "quicklist"
|
||||
if os.environ["REDIS_VERSION"] == "7":
|
||||
if version_parse(os.environ["REDIS_VERSION"]) >= version_parse("7"):
|
||||
zset_type = "listpack"
|
||||
hash_type = "listpack"
|
||||
list_type = "listpack"
|
||||
|
@ -40,7 +42,7 @@ if os.environ["REDIS_VERSION"] == "7":
|
|||
],
|
||||
)
|
||||
def test_send_command(_input, command_name, expect_args):
|
||||
client = Client("127.0.0.1", "6379", None)
|
||||
client = Client("127.0.0.1", 6379, None)
|
||||
client.execute = MagicMock()
|
||||
next(client.send_command(_input, None))
|
||||
args, _ = client.execute.call_args
|
||||
|
@ -180,7 +182,7 @@ def test_not_retry_on_authentication_error(iredis_client, config):
|
|||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
"int(os.environ['REDIS_VERSION']) != 6",
|
||||
"version_parse(os.environ['REDIS_VERSION']) != version_parse('6')",
|
||||
reason="""
|
||||
in redis7, it will not work if you:
|
||||
1. connect redis without password
|
||||
|
@ -213,7 +215,7 @@ def test_auto_select_db_and_auth_for_reconnect_only_6(iredis_client, config):
|
|||
)
|
||||
|
||||
|
||||
@pytest.mark.skipif("int(os.environ['REDIS_VERSION']) > 5")
|
||||
@pytest.mark.skipif("version_parse(os.environ['REDIS_VERSION']) > version_parse('5')")
|
||||
def test_auto_select_db_and_auth_for_reconnect_only_5(iredis_client, config):
|
||||
config.retry_times = 2
|
||||
config.raw = True
|
||||
|
@ -554,23 +556,29 @@ def test_version_parse_for_auth(iredis_client):
|
|||
"info, version",
|
||||
[
|
||||
(
|
||||
"# Server\r\nredis_version:df--128-NOTFOUND\r\n"
|
||||
"redis_mode:standalone\r\narch_bits:64",
|
||||
(
|
||||
"# Server\r\nredis_version:df--128-NOTFOUND\r\n"
|
||||
"redis_mode:standalone\r\narch_bits:64"
|
||||
),
|
||||
"df--128-NOTFOUND",
|
||||
),
|
||||
(
|
||||
"# Server\r\nredis_version:6.2.5\r\n"
|
||||
"redis_git_sha1:00000000\r\n"
|
||||
"redis_git_dirty:0\r\n"
|
||||
"redis_build_id:915e5480613bc9b6\r\n"
|
||||
"redis_mode:standalone ",
|
||||
(
|
||||
"# Server\r\nredis_version:6.2.5\r\n"
|
||||
"redis_git_sha1:00000000\r\n"
|
||||
"redis_git_dirty:0\r\n"
|
||||
"redis_build_id:915e5480613bc9b6\r\n"
|
||||
"redis_mode:standalone "
|
||||
),
|
||||
"6.2.5",
|
||||
),
|
||||
(
|
||||
"# Server\r\nredis_version:5.0.14.1\r\n"
|
||||
"redis_git_sha1:00000000\r\nredis_git_dirty:0\r\n"
|
||||
"redis_build_id:915e5480613bc9b6\r\n"
|
||||
"redis_mode:standalone ",
|
||||
(
|
||||
"# Server\r\nredis_version:5.0.14.1\r\n"
|
||||
"redis_git_sha1:00000000\r\nredis_git_dirty:0\r\n"
|
||||
"redis_build_id:915e5480613bc9b6\r\n"
|
||||
"redis_mode:standalone "
|
||||
),
|
||||
"5.0.14.1",
|
||||
),
|
||||
],
|
||||
|
@ -580,9 +588,10 @@ def test_version_path(info, version):
|
|||
mock_config.no_info = True
|
||||
mock_config.pager = "less"
|
||||
mock_config.version = "5.0.0"
|
||||
mock_config.decode = "utf-8"
|
||||
with patch("iredis.client.Client.execute") as mock_execute:
|
||||
mock_execute.return_value = info
|
||||
client = Client("127.0.0.1", "6379", None)
|
||||
client = Client("127.0.0.1", 6379)
|
||||
client.get_server_info()
|
||||
assert mock_config.version == version
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue