1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

DOC-4423: add TCEs for various command pages (#2885)

* DOC-4423: add TCEs for various command pages

* fix problematic doctest

from redis docs for ACL DELUSER:
Delete all the specified ACL users and terminate all the connections
 that are authenticated with such users

Nodejs complains: Warning: Detected unsettled top-level await
which in turn gives the error code 13 in the workflow

await client.auth({ username: 'test-user' ...});
// deleting the user that is currently logged in -> bad
await client.sendCommand(['ACL', 'DELUSER', 'test-user']);
await client.quit()

fix: authenticate with the default user before deleting the test-user

---------

Co-authored-by: Nikolay Karadzhov <nkaradzhov89@gmail.com>
This commit is contained in:
David Dougherty
2025-04-22 07:50:35 -07:00
committed by GitHub
parent 001087f520
commit cb26059e5d
5 changed files with 306 additions and 1 deletions

44
doctests/cmds-set.js Normal file
View File

@@ -0,0 +1,44 @@
// EXAMPLE: cmds_set
// REMOVE_START
import assert from 'node:assert';
// REMOVE_END
// HIDE_START
import { createClient } from 'redis';
const client = createClient();
await client.connect().catch(console.error);
// HIDE_END
// STEP_START sadd
const res1 = await client.sAdd('myset', ['Hello', 'World']);
console.log(res1); // 2
const res2 = await client.sAdd('myset', ['World']);
console.log(res2); // 0
const res3 = await client.sMembers('myset')
console.log(res3); // ['Hello', 'World']
// REMOVE_START
assert.deepEqual(res3, ['Hello', 'World']);
await client.del('myset');
// REMOVE_END
// STEP_END
// STEP_START smembers
const res4 = await client.sAdd('myset', ['Hello', 'World']);
console.log(res4); // 2
const res5 = await client.sMembers('myset')
console.log(res5); // ['Hello', 'World']
// REMOVE_START
assert.deepEqual(res5, ['Hello', 'World']);
await client.del('myset');
// REMOVE_END
// STEP_END
// HIDE_START
await client.quit();
// HIDE_END