Fix LPOS when member not in list.

This commit ensures an empty List is returned in the case the member does not exist in the target list.

See #1957.
Original pull request: #1962.
This commit is contained in:
Christoph Strobl
2021-02-10 14:35:34 +01:00
committed by Mark Paluch
parent 19eb0930cd
commit 840c7f50ca
4 changed files with 22 additions and 2 deletions

View File

@@ -1464,6 +1464,16 @@ public abstract class AbstractConnectionIntegrationTests {
assertThat((List<Long>) getResults().get(1)).containsExactly(2L, 6L, 7L);
}
@Test // GH-1957
@EnabledOnCommand("LPOS")
void lPosNonExisting() {
actual.add(connection.rPush("mylist", "a", "b", "c", "1", "2", "3", "c", "c"));
actual.add(connection.lPos("mylist", "x", null, null));
assertThat((List<Long>) getResults().get(1)).isEmpty();
}
// Set operations
@Test

View File

@@ -2534,4 +2534,14 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests {
assertThat(result).containsExactly(2L, 6L, 7L);
}
@Test // GH-1957
@EnabledOnCommand("LPOS")
void lPosNonExisting() {
nativeConnection.rpush(KEY_1, "a", "b", "c", "1", "2", "3", "c", "c");
List<Long> result = clusterConnection.listCommands().lPos(KEY_1_BYTES, "x".getBytes(StandardCharsets.UTF_8), null, null);
assertThat(result).isEmpty();
}
}