-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathblmpop.test.ts
93 lines (84 loc) · 5.91 KB
/
blmpop.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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/blmpop.md example 1", async () => {
const outputs: Record<string, unknown> = {};
outputs.r0 = await client.del("mylist", "mylist2");
outputs.r1 = await client.lpush("mylist", "one", "two", "three", "four", "five");
// Error decoding command `BLMPOP 1 1 mylist LEFT COUNT 2`:
// decoding BLMPOP overload 0 (timeout,numkeys,where): {name:'timeout',schema:{title:'timeout',type:'number'}},{name:'numkeys',schema:{title:'numkeys',type:'integer'}},{name:'where',schema:{title:'where',type:'string',enum:['LEFT','RIGHT']}}
// 1 successfully decoded as timeout (string). Decoded value 1. Tokens remaining [1,mylist,LEFT,COUNT,2], target args remainin count: 2
// 1 successfully decoded as numkeys (string). Decoded value 1. Tokens remaining [mylist,LEFT,COUNT,2], target args remainin count: 1
// Expected one of LEFT,RIGHT, got mylist
// ---
// [...truncated]
// decoding BLMPOP overload 3 (timeout,numkeys,key,where,COUNT): {name:'timeout',schema:{title:'timeout',type:'number'}},{name:'numkeys',schema:{title:'numkeys',type:'integer'}},{name:'key',optional:true,schema:{title:'key',type:'array',items:{title:'key',type:'string'}}},{name:'where',schema:{title:'where',type:'string',enum:['LEFT','RIGHT']}},{name:'COUNT',optional:true,schema:{title:'COUNT',type:'array',items:[{type:'string',const:'COUNT'},{title:'count',type:'integer'}]}}
// 1 successfully decoded as timeout (string). Decoded value 1. Tokens remaining [1,mylist,LEFT,COUNT,2], target args remainin count: 4
// 1 successfully decoded as numkeys (string). Decoded value 1. Tokens remaining [mylist,LEFT,COUNT,2], target args remainin count: 3
// Not smart enough to deal with arrays in the beginning or middle of arg lists
// ---
outputs.r3 = await client.lrange("mylist", 0, -1);
outputs.r4 = await client.lpush("mylist2", "a", "b", "c", "d", "e");
// Error decoding command `BLMPOP 1 2 mylist mylist2 LEFT COUNT 3`:
// decoding BLMPOP overload 0 (timeout,numkeys,where): {name:'timeout',schema:{title:'timeout',type:'number'}},{name:'numkeys',schema:{title:'numkeys',type:'integer'}},{name:'where',schema:{title:'where',type:'string',enum:['LEFT','RIGHT']}}
// 1 successfully decoded as timeout (string). Decoded value 1. Tokens remaining [2,mylist,mylist2,LEFT,COUNT,3], target args remainin count: 2
// 2 successfully decoded as numkeys (string). Decoded value 2. Tokens remaining [mylist,mylist2,LEFT,COUNT,3], target args remainin count: 1
// Expected one of LEFT,RIGHT, got mylist
// ---
// [...truncated]
// decoding BLMPOP overload 3 (timeout,numkeys,key,where,COUNT): {name:'timeout',schema:{title:'timeout',type:'number'}},{name:'numkeys',schema:{title:'numkeys',type:'integer'}},{name:'key',optional:true,schema:{title:'key',type:'array',items:{title:'key',type:'string'}}},{name:'where',schema:{title:'where',type:'string',enum:['LEFT','RIGHT']}},{name:'COUNT',optional:true,schema:{title:'COUNT',type:'array',items:[{type:'string',const:'COUNT'},{title:'count',type:'integer'}]}}
// 1 successfully decoded as timeout (string). Decoded value 1. Tokens remaining [2,mylist,mylist2,LEFT,COUNT,3], target args remainin count: 4
// 2 successfully decoded as numkeys (string). Decoded value 2. Tokens remaining [mylist,mylist2,LEFT,COUNT,3], target args remainin count: 3
// Not smart enough to deal with arrays in the beginning or middle of arg lists
// ---
outputs.r6 = await client.lrange("mylist", 0, -1);
// Error decoding command `BLMPOP 1 2 mylist mylist2 RIGHT COUNT 10`:
// decoding BLMPOP overload 0 (timeout,numkeys,where): {name:'timeout',schema:{title:'timeout',type:'number'}},{name:'numkeys',schema:{title:'numkeys',type:'integer'}},{name:'where',schema:{title:'where',type:'string',enum:['LEFT','RIGHT']}}
// 1 successfully decoded as timeout (string). Decoded value 1. Tokens remaining [2,mylist,mylist2,RIGHT,COUNT,10], target args remainin count: 2
// 2 successfully decoded as numkeys (string). Decoded value 2. Tokens remaining [mylist,mylist2,RIGHT,COUNT,10], target args remainin count: 1
// Expected one of LEFT,RIGHT, got mylist
// ---
// [...truncated]
// decoding BLMPOP overload 3 (timeout,numkeys,key,where,COUNT): {name:'timeout',schema:{title:'timeout',type:'number'}},{name:'numkeys',schema:{title:'numkeys',type:'integer'}},{name:'key',optional:true,schema:{title:'key',type:'array',items:{title:'key',type:'string'}}},{name:'where',schema:{title:'where',type:'string',enum:['LEFT','RIGHT']}},{name:'COUNT',optional:true,schema:{title:'COUNT',type:'array',items:[{type:'string',const:'COUNT'},{title:'count',type:'integer'}]}}
// 1 successfully decoded as timeout (string). Decoded value 1. Tokens remaining [2,mylist,mylist2,RIGHT,COUNT,10], target args remainin count: 4
// 2 successfully decoded as numkeys (string). Decoded value 2. Tokens remaining [mylist,mylist2,RIGHT,COUNT,10], target args remainin count: 3
// Not smart enough to deal with arrays in the beginning or middle of arg lists
// ---
outputs.r8 = await client.lrange("mylist2", 0, -1);
outputs.r9 = await client.exists("mylist", "mylist2");
expect(fuzzify(outputs, __filename)).toMatchInlineSnapshot(`
Object {
"r0": 0,
"r1": 5,
"r3": Array [
"five",
"four",
"three",
"two",
"one",
],
"r4": 5,
"r6": Array [
"five",
"four",
"three",
"two",
"one",
],
"r8": Array [
"e",
"d",
"c",
"b",
"a",
],
"r9": 2,
}
`);
});