Skip to content

Commit b57c4f5

Browse files
committed
test: add hScanValuesIterator regression test
Uses distinct field/value pairs and asserts the iterator yields the hash values, so it fails against the previous field-name behavior.
1 parent 29896b9 commit b57c4f5

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

‎packages/client/lib/client/index.spec.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,30 @@ describe('Client', () => {
985985
minimumDockerVersion: [7, 4]
986986
});
987987

988+
testUtils.testWithClient('hScanValuesIterator', async client => {
989+
const hash: Record<string, string> = {};
990+
const expectedValues: Array<string> = [];
991+
for (let i = 0; i < 100; i++) {
992+
hash[i.toString()] = `value${i}`;
993+
expectedValues.push(`value${i}`);
994+
}
995+
996+
await client.hSet('key', hash);
997+
998+
const actualValues: Array<string> = [];
999+
for await (const values of client.hScanValuesIterator('key')) {
1000+
for (const value of values) {
1001+
actualValues.push(value);
1002+
}
1003+
}
1004+
1005+
function sort(a: string, b: string) {
1006+
return Number(a.slice('value'.length)) - Number(b.slice('value'.length));
1007+
}
1008+
1009+
assert.deepEqual(actualValues.sort(sort), expectedValues);
1010+
}, GLOBAL.SERVERS.OPEN);
1011+
9881012
testUtils.testWithClient('sScanIterator', async client => {
9891013
const members = new Set<string>();
9901014
for (let i = 0; i < 100; i++) {

0 commit comments

Comments
 (0)