-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathexpire.test.ts
38 lines (32 loc) · 1.11 KB
/
expire.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { createNodeRedisClient } from "../../../src";
import { fuzzify } from "../../fuzzify";
const client = createNodeRedisClient();
beforeAll(async () => {
await client.ping();
});
beforeEach(async () => {
await client.flushall();
});
test("docs/redis-doc/commands/expire.md example 1", async () => {
const outputs: Record<string, unknown> = {};
outputs.r0 = await client.set("mykey", "Hello");
outputs.r1 = await client.expire("mykey", 10);
outputs.r2 = await client.ttl("mykey");
outputs.r3 = await client.set("mykey", "Hello World");
outputs.r4 = await client.ttl("mykey");
// "XX","NX" not supported in redis v6! outputs.r5 = await client.expire("mykey",10,"XX")
outputs.r6 = await client.ttl("mykey");
// "XX","NX" not supported in redis v6! outputs.r7 = await client.expire("mykey",10,"NX")
outputs.r8 = await client.ttl("mykey");
expect(fuzzify(outputs, __filename)).toMatchInlineSnapshot(`
Object {
"r0": "OK",
"r1": 1,
"r2": 10,
"r3": "OK",
"r4": -1,
"r6": -1,
"r8": -1,
}
`);
});