Skip to content

Commit 76d36f2

Browse files
authored
make tests faster
1 parent 6021b32 commit 76d36f2

File tree

1 file changed

+49
-45
lines changed

1 file changed

+49
-45
lines changed

packages/client/lib/commands/XAUTOCLAIM.spec.ts

+49-45
Original file line numberDiff line numberDiff line change
@@ -24,71 +24,75 @@ describe('XAUTOCLAIM', () => {
2424
});
2525

2626
testUtils.testWithClient('client.xAutoClaim without messages', async client => {
27-
await Promise.all([
27+
const [,, reply] = await Promise.all([
2828
client.xGroupCreate('key', 'group', '$', { MKSTREAM: true }),
2929
client.xGroupCreateConsumer('key', 'group', 'consumer'),
30+
client.xAutoClaim('key', 'group', 'consumer', 1, '0-0')
3031
]);
3132

32-
assert.deepEqual(
33-
await client.xAutoClaim('key', 'group', 'consumer', 1, '0-0'),
34-
{
35-
nextId: '0-0',
36-
messages: []
37-
}
38-
);
33+
assert.deepEqual(reply, {
34+
nextId: '0-0',
35+
messages: []
36+
});
3937
}, GLOBAL.SERVERS.OPEN);
4038

4139
testUtils.testWithClient('client.xAutoClaim with messages', async client => {
42-
await client.xGroupCreate('key', 'group', '$', { MKSTREAM: true });
43-
await client.xGroupCreateConsumer('key', 'group', 'consumer');
44-
const id = await client.xAdd('key', '*', { foo: 'bar' });
45-
await client.xReadGroup('group', 'consumer', { key: 'key', id: '>' });
40+
const [,, id,, reply] = await Promise.all([
41+
client.xGroupCreate('key', 'group', '$', { MKSTREAM: true }),
42+
client.xGroupCreateConsumer('key', 'group', 'consumer'),
43+
client.xAdd('key', '*', { foo: 'bar' }),
44+
client.xReadGroup('group', 'consumer', { key: 'key', id: '>' }),
45+
client.xAutoClaim('key', 'group', 'consumer', 0, '0-0')
46+
]);
4647

47-
assert.deepEqual(
48-
await client.xAutoClaim('key', 'group', 'consumer', 0, '0-0'),
49-
{
50-
nextId: '0-0',
51-
messages: [{
52-
id,
53-
message: Object.create(null, { 'foo': {
48+
assert.deepEqual(reply, {
49+
nextId: '0-0',
50+
messages: [{
51+
id,
52+
message: Object.create(null, {
53+
foo: {
5454
value: 'bar',
5555
configurable: true,
5656
enumerable: true
57-
} })
58-
}]
59-
}
60-
);
57+
}
58+
})
59+
}]
60+
});
6161
}, GLOBAL.SERVERS.OPEN);
6262

6363
testUtils.testWithClient('client.xAutoClaim with trimmed messages', async client => {
64-
await client.xGroupCreate('key', 'group', '$', { MKSTREAM: true });
65-
await client.xGroupCreateConsumer('key', 'group', 'consumer');
66-
await client.xAdd('key', '*', { foo: 'bar' });
67-
await client.xReadGroup('group', 'consumer', { key: 'key', id: '>' });
68-
await client.xTrim('key', 'MAXLEN', 0);
69-
const id = await client.xAdd('key', '*', { bar: 'baz' });
70-
await client.xReadGroup('group', 'consumer', { key: 'key', id: '>' });
64+
const [,,,,, id,, reply] = await Promise.all([
65+
client.xGroupCreate('key', 'group', '$', { MKSTREAM: true }),
66+
client.xGroupCreateConsumer('key', 'group', 'consumer'),
67+
client.xAdd('key', '*', { foo: 'bar' }),
68+
client.xReadGroup('group', 'consumer', { key: 'key', id: '>' }),
69+
client.xTrim('key', 'MAXLEN', 0),
70+
client.xAdd('key', '*', { bar: 'baz' }),
71+
client.xReadGroup('group', 'consumer', { key: 'key', id: '>' }),
72+
client.xAutoClaim('key', 'group', 'consumer', 0, '0-0')
73+
]);
7174

72-
assert.deepEqual(
73-
await client.xAutoClaim('key', 'group', 'consumer', 0, '0-0'),
74-
{
75-
nextId: '0-0',
76-
messages: testUtils.isVersionGreaterThan([7, 0]) ? [{
77-
id,
78-
message: Object.create(null, { 'bar': {
75+
assert.deepEqual(reply, {
76+
nextId: '0-0',
77+
messages: testUtils.isVersionGreaterThan([7, 0]) ? [{
78+
id,
79+
message: Object.create(null, {
80+
bar: {
7981
value: 'baz',
8082
configurable: true,
8183
enumerable: true
82-
} })
83-
}] : [null, {
84-
id,
85-
message: Object.create(null, { 'bar': {
84+
}
85+
})
86+
}] : [null, {
87+
id,
88+
message: Object.create(null, {
89+
bar: {
8690
value: 'baz',
8791
configurable: true,
8892
enumerable: true
89-
} })
90-
}]
91-
}
92-
);
93+
}
94+
})
95+
}]
96+
});
9397
}, GLOBAL.SERVERS.OPEN);
9498
});

0 commit comments

Comments
 (0)