Skip to content

Commit 602b860

Browse files
committed
feat(tests): Update functional tests
1 parent f56d7bb commit 602b860

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

  • packages/functional-tests/lib

packages/functional-tests/lib/sms.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,31 @@ export class SmsClient {
2929
const expires = Date.now() + timeout;
3030

3131
while (Date.now() < expires) {
32-
const keys = await this.client.keys(redisKeyPattern);
32+
let cursor = '0';
3333
let newestKey: string | null = null;
3434
let newestCreatedAt = -1;
3535

36-
for (const key of keys) {
37-
const valueRaw = await this.client.get(key);
38-
if (!valueRaw) {
39-
continue;
40-
}
41-
const value = JSON.parse(valueRaw);
36+
do {
37+
const [newCursor, keys] = await this.client.scan(
38+
cursor,
39+
'MATCH',
40+
redisKeyPattern
41+
);
42+
cursor = newCursor;
43+
44+
for (const key of keys) {
45+
const valueRaw = await this.client.get(key);
46+
if (!valueRaw) {
47+
continue;
48+
}
49+
const value = JSON.parse(valueRaw);
4250

43-
if (!newestKey || value.createdAt > newestCreatedAt) {
44-
newestKey = key;
45-
newestCreatedAt = value.createdAt;
51+
if (!newestKey || value.createdAt > newestCreatedAt) {
52+
newestKey = key;
53+
newestCreatedAt = value.createdAt;
54+
}
4655
}
47-
}
56+
} while (cursor !== '0');
4857

4958
// If no keys are found, wait and try again.
5059
if (!newestKey) {

0 commit comments

Comments
 (0)