diff --git a/tests/test_backend.py b/tests/test_backend.py index 7ac99da..be46b66 100644 --- a/tests/test_backend.py +++ b/tests/test_backend.py @@ -765,6 +765,25 @@ def test_iter_keys_generator(self, cache: ValkeyCache): next_value = next(result) assert next_value is not None + def test_scan(self, cache: ValkeyCache): + if isinstance(cache.client, ShardClient): + pytest.skip("ShardClient doesn't support scan") + + cache.set("foo", "bar") + cursor, result = cache.scan() + assert result == ["foo"] + assert cursor == 0 + + def test_scan_with_match(self, cache: ValkeyCache): + if cache.client._has_compression_enabled(): + pytest.skip("Compression is enabled, scan match is not supported") + if isinstance(cache.client, ShardClient): + pytest.skip("ShardClient doesn't support scan") + + cache.set("foo", "bar") + _, result = cache.scan(match="f*") + assert result == ["foo"] + def test_primary_replica_switching(self, cache: ValkeyCache): if isinstance(cache.client, ShardClient): pytest.skip("ShardClient doesn't support get_client") diff --git a/tests/tests_async/test_backend.py b/tests/tests_async/test_backend.py index 82400ad..da62f3a 100644 --- a/tests/tests_async/test_backend.py +++ b/tests/tests_async/test_backend.py @@ -799,6 +799,20 @@ async def test_primary_replica_switching(self, cache: AsyncValkeyCache): assert await client.get_client(write=True) == "Foo" assert await client.get_client(write=False) == "Bar" + async def test_scan(self, cache: AsyncValkeyCache): + await cache.aset("foo", "bar") + cursor, result = await cache.ascan() + assert result == ["foo"] + assert cursor == 0 + + async def test_scan_with_match(self, cache: AsyncValkeyCache): + if cache.client._has_compression_enabled(): + pytest.skip("Compression is enabled, scan match is not supported") + + await cache.aset("foo", "bar") + _, result = await cache.ascan(match="f*") + assert result == ["foo"] + async def test_primary_replica_switching_with_index(self, cache: AsyncValkeyCache): # if isinstance(cache.client, ShardClient): # pytest.skip("ShardClient doesn't support get_client")