1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00
This commit is contained in:
Leibale
2023-04-27 18:41:32 -04:00
parent 69767d40f8
commit ab3973aca3
51 changed files with 1468 additions and 1432 deletions

View File

@@ -242,7 +242,7 @@ export class Decoder {
private _maybeDecodeNumberValue(isNegative, chunk) { private _maybeDecodeNumberValue(isNegative, chunk) {
const cb = this._decodeUnsingedNumber.bind(this, 0); const cb = this._decodeUnsingedNumber.bind(this, 0);
return this._cursor === chunk.length ? return ++this._cursor === chunk.length ?
this._decodeNumberValue.bind(isNegative, cb) : this._decodeNumberValue.bind(isNegative, cb) :
this._decodeNumberValue(isNegative, cb, chunk); this._decodeNumberValue(isNegative, cb, chunk);
} }

View File

@@ -56,4 +56,3 @@ export default {
transformArguments: transformSortArguments.bind(undefined, 'SORT'), transformArguments: transformSortArguments.bind(undefined, 'SORT'),
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply> transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
} as const satisfies Command; } as const satisfies Command;

View File

@@ -1,28 +1,28 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './SPOP'; // import { transformArguments } from './SPOP';
describe('SPOP', () => { // describe('SPOP', () => {
describe('transformArguments', () => { // describe('transformArguments', () => {
it('simple', () => { // it('simple', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key'), // transformArguments('key'),
['SPOP', 'key'] // ['SPOP', 'key']
); // );
}); // });
it('with count', () => { // it('with count', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 2), // transformArguments('key', 2),
['SPOP', 'key', '2'] // ['SPOP', 'key', '2']
); // );
}); // });
}); // });
testUtils.testWithClient('client.sPop', async client => { // testUtils.testWithClient('client.sPop', async client => {
assert.equal( // assert.equal(
await client.sPop('key'), // await client.sPop('key'),
null // null
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,21 +1,24 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './SPUBLISH'; import SPUBLISH from './SPUBLISH';
describe('SPUBLISH', () => { describe('SPUBLISH', () => {
testUtils.isVersionGreaterThanHook([7]); testUtils.isVersionGreaterThanHook([7]);
it('transformArguments', () => {
assert.deepEqual(
transformArguments('channel', 'message'),
['SPUBLISH', 'channel', 'message']
);
});
testUtils.testWithClient('client.sPublish', async client => { it('transformArguments', () => {
assert.equal( assert.deepEqual(
await client.sPublish('channel', 'message'), SPUBLISH.transformArguments('channel', 'message'),
0 ['SPUBLISH', 'channel', 'message']
); );
}, GLOBAL.SERVERS.OPEN); });
testUtils.testAll('sPublish', async client => {
assert.equal(
await client.sPublish('channel', 'message'),
0
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
}); });

View File

@@ -1,19 +1,22 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './SRANDMEMBER'; import SRANDMEMBER from './SRANDMEMBER';
describe('SRANDMEMBER', () => { describe('SRANDMEMBER', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('key'), SRANDMEMBER.transformArguments('key'),
['SRANDMEMBER', 'key'] ['SRANDMEMBER', 'key']
); );
}); });
testUtils.testWithClient('client.sRandMember', async client => { testUtils.testAll('sRandMember', async client => {
assert.equal( assert.equal(
await client.sRandMember('key'), await client.sRandMember('key'),
null null
); );
}, GLOBAL.SERVERS.OPEN); }, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
}); });

View File

@@ -1,19 +1,22 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './SRANDMEMBER_COUNT'; import SRANDMEMBER_COUNT from './SRANDMEMBER_COUNT';
describe('SRANDMEMBER COUNT', () => { describe('SRANDMEMBER COUNT', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('key', 1), SRANDMEMBER_COUNT.transformArguments('key', 1),
['SRANDMEMBER', 'key', '1'] ['SRANDMEMBER', 'key', '1']
); );
}); });
testUtils.testWithClient('client.sRandMemberCount', async client => { testUtils.testAll('sRandMemberCount', async client => {
assert.deepEqual( assert.deepEqual(
await client.sRandMemberCount('key', 1), await client.sRandMemberCount('key', 1),
[] []
); );
}, GLOBAL.SERVERS.OPEN); }, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
}); });

View File

@@ -1,16 +1,13 @@
// import { RedisCommandArgument, RedisCommandArguments } from '.'; import { RedisArgument, ArrayReply, BlobStringReply, Command } from '../RESP/types';
// import { transformArguments as transformSRandMemberArguments } from './SRANDMEMBER'; import SRANDMEMBER from './SRANDMEMBER';
// export { FIRST_KEY_INDEX } from './SRANDMEMBER'; export default {
FIRST_KEY_INDEX: SRANDMEMBER.FIRST_KEY_INDEX,
// export function transformArguments( IS_READ_ONLY: SRANDMEMBER.IS_READ_ONLY,
// key: RedisCommandArgument, transformArguments(key: RedisArgument, count: number) {
// count: number const args = SRANDMEMBER.transformArguments(key);
// ): RedisCommandArguments { args.push(count.toString());
// return [ return args;
// ...transformSRandMemberArguments(key), },
// count.toString() transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
// ]; } as const satisfies Command;
// }
// export declare function transformReply(): Array<RedisCommandArgument>;

View File

@@ -1,28 +1,31 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './SREM'; import SREM from './SREM';
describe('SREM', () => { describe('SREM', () => {
describe('transformArguments', () => { describe('transformArguments', () => {
it('string', () => { it('string', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('key', 'member'), SREM.transformArguments('key', 'member'),
['SREM', 'key', 'member'] ['SREM', 'key', 'member']
); );
});
it('array', () => {
assert.deepEqual(
transformArguments('key', ['1', '2']),
['SREM', 'key', '1', '2']
);
});
}); });
testUtils.testWithClient('client.sRem', async client => { it('array', () => {
assert.equal( assert.deepEqual(
await client.sRem('key', 'member'), SREM.transformArguments('key', ['1', '2']),
0 ['SREM', 'key', '1', '2']
); );
}, GLOBAL.SERVERS.OPEN); });
});
testUtils.testAll('client.sRem', async client => {
assert.equal(
await client.sRem('key', 'member'),
0
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
}); });

View File

@@ -1,74 +1,52 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './SSCAN'; import SSCAN from './SSCAN';
describe('SSCAN', () => { describe('SSCAN', () => {
describe('transformArguments', () => { describe('transformArguments', () => {
it('cusror only', () => { it('cusror only', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('key', 0), SSCAN.transformArguments('key', 0),
['SSCAN', 'key', '0'] ['SSCAN', 'key', '0']
); );
});
it('with MATCH', () => {
assert.deepEqual(
transformArguments('key', 0, {
MATCH: 'pattern'
}),
['SSCAN', 'key', '0', 'MATCH', 'pattern']
);
});
it('with COUNT', () => {
assert.deepEqual(
transformArguments('key', 0, {
COUNT: 1
}),
['SSCAN', 'key', '0', 'COUNT', '1']
);
});
it('with MATCH & COUNT', () => {
assert.deepEqual(
transformArguments('key', 0, {
MATCH: 'pattern',
COUNT: 1
}),
['SSCAN', 'key', '0', 'MATCH', 'pattern', 'COUNT', '1']
);
});
}); });
describe('transformReply', () => { it('with MATCH', () => {
it('without members', () => { assert.deepEqual(
assert.deepEqual( SSCAN.transformArguments('key', 0, {
transformReply(['0', []]), MATCH: 'pattern'
{ }),
cursor: 0, ['SSCAN', 'key', '0', 'MATCH', 'pattern']
members: [] );
}
);
});
it('with members', () => {
assert.deepEqual(
transformReply(['0', ['member']]),
{
cursor: 0,
members: ['member']
}
);
});
}); });
testUtils.testWithClient('client.sScan', async client => { it('with COUNT', () => {
assert.deepEqual( assert.deepEqual(
await client.sScan('key', 0), SSCAN.transformArguments('key', 0, {
{ COUNT: 1
cursor: 0, }),
members: [] ['SSCAN', 'key', '0', 'COUNT', '1']
} );
); });
}, GLOBAL.SERVERS.OPEN);
it('with MATCH & COUNT', () => {
assert.deepEqual(
SSCAN.transformArguments('key', 0, {
MATCH: 'pattern',
COUNT: 1
}),
['SSCAN', 'key', '0', 'MATCH', 'pattern', 'COUNT', '1']
);
});
});
testUtils.testWithClient('client.sScan', async client => {
assert.deepEqual(
await client.sScan('key', 0),
{
cursor: 0,
members: []
}
);
}, GLOBAL.SERVERS.OPEN);
}); });

View File

@@ -1,26 +1,22 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './STRLEN'; import STRLEN from './STRLEN';
describe('STRLEN', () => { describe('STRLEN', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('key'), STRLEN.transformArguments('key'),
['STRLEN', 'key'] ['STRLEN', 'key']
); );
}); });
testUtils.testWithClient('client.strLen', async client => { testUtils.testAll('strLen', async client => {
assert.equal( assert.equal(
await client.strLen('key'), await client.strLen('key'),
0 0
); );
}, GLOBAL.SERVERS.OPEN); }, {
client: GLOBAL.SERVERS.OPEN,
testUtils.testWithCluster('cluster.strLen', async cluster => { cluster: GLOBAL.CLUSTERS.OPEN
assert.equal( });
await cluster.strLen('key'),
0
);
}, GLOBAL.CLUSTERS.OPEN);
}); });

View File

@@ -1,28 +1,28 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './SUNION'; // import { transformArguments } from './SUNION';
describe('SUNION', () => { // describe('SUNION', () => {
describe('transformArguments', () => { // describe('transformArguments', () => {
it('string', () => { // it('string', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key'), // transformArguments('key'),
['SUNION', 'key'] // ['SUNION', 'key']
); // );
}); // });
it('array', () => { // it('array', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments(['1', '2']), // transformArguments(['1', '2']),
['SUNION', '1', '2'] // ['SUNION', '1', '2']
); // );
}); // });
}); // });
testUtils.testWithClient('client.sUnion', async client => { // testUtils.testWithClient('client.sUnion', async client => {
assert.deepEqual( // assert.deepEqual(
await client.sUnion('key'), // await client.sUnion('key'),
[] // []
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,28 +1,28 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './SUNIONSTORE'; // import { transformArguments } from './SUNIONSTORE';
describe('SUNIONSTORE', () => { // describe('SUNIONSTORE', () => {
describe('transformArguments', () => { // describe('transformArguments', () => {
it('string', () => { // it('string', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('destination', 'key'), // transformArguments('destination', 'key'),
['SUNIONSTORE', 'destination', 'key'] // ['SUNIONSTORE', 'destination', 'key']
); // );
}); // });
it('array', () => { // it('array', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('destination', ['1', '2']), // transformArguments('destination', ['1', '2']),
['SUNIONSTORE', 'destination', '1', '2'] // ['SUNIONSTORE', 'destination', '1', '2']
); // );
}); // });
}); // });
testUtils.testWithClient('client.sUnionStore', async client => { // testUtils.testWithClient('client.sUnionStore', async client => {
assert.equal( // assert.equal(
await client.sUnionStore('destination', 'key'), // await client.sUnionStore('destination', 'key'),
0 // 0
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,19 +1,19 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './SWAPDB'; // import { transformArguments } from './SWAPDB';
describe('SWAPDB', () => { // describe('SWAPDB', () => {
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments(0, 1), // transformArguments(0, 1),
['SWAPDB', '0', '1'] // ['SWAPDB', '0', '1']
); // );
}); // });
testUtils.testWithClient('client.swapDb', async client => { // testUtils.testWithClient('client.swapDb', async client => {
assert.equal( // assert.equal(
await client.swapDb(0, 1), // await client.swapDb(0, 1),
'OK' // 'OK'
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,5 +1,5 @@
export function transformArguments(index1: number, index2: number): Array<string> { // export function transformArguments(index1: number, index2: number): Array<string> {
return ['SWAPDB', index1.toString(), index2.toString()]; // return ['SWAPDB', index1.toString(), index2.toString()];
} // }
export declare function transformReply(): string; // export declare function transformReply(): string;

View File

@@ -1,18 +1,18 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './TIME'; // import { transformArguments } from './TIME';
describe('TIME', () => { // describe('TIME', () => {
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments(), // transformArguments(),
['TIME'] // ['TIME']
); // );
}); // });
testUtils.testWithClient('client.time', async client => { // testUtils.testWithClient('client.time', async client => {
const reply = await client.time(); // const reply = await client.time();
assert.ok(reply instanceof Date); // assert.ok(reply instanceof Date);
assert.ok(typeof reply.microseconds === 'number'); // assert.ok(typeof reply.microseconds === 'number');
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,15 +1,15 @@
export function transformArguments(): Array<string> { // export function transformArguments(): Array<string> {
return ['TIME']; // return ['TIME'];
} // }
interface TimeReply extends Date { // interface TimeReply extends Date {
microseconds: number; // microseconds: number;
} // }
export function transformReply(reply: [string, string]): TimeReply { // export function transformReply(reply: [string, string]): TimeReply {
const seconds = Number(reply[0]), // const seconds = Number(reply[0]),
microseconds = Number(reply[1]), // microseconds = Number(reply[1]),
d: Partial<TimeReply> = new Date(seconds * 1000 + microseconds / 1000); // d: Partial<TimeReply> = new Date(seconds * 1000 + microseconds / 1000);
d.microseconds = microseconds; // d.microseconds = microseconds;
return d as TimeReply; // return d as TimeReply;
} // }

View File

@@ -1,28 +1,31 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './TOUCH'; import TOUCH from './TOUCH';
describe('TOUCH', () => { describe('TOUCH', () => {
describe('transformArguments', () => { describe('transformArguments', () => {
it('string', () => { it('string', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('key'), TOUCH.transformArguments('key'),
['TOUCH', 'key'] ['TOUCH', 'key']
); );
});
it('array', () => {
assert.deepEqual(
transformArguments(['1', '2']),
['TOUCH', '1', '2']
);
});
}); });
testUtils.testWithClient('client.touch', async client => { it('array', () => {
assert.equal( assert.deepEqual(
await client.touch('key'), TOUCH.transformArguments(['1', '2']),
0 ['TOUCH', '1', '2']
); );
}, GLOBAL.SERVERS.OPEN); });
});
testUtils.testAll('touch', async client => {
assert.equal(
await client.touch('key'),
0
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
}); });

View File

@@ -1,19 +1,23 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './TTL'; import TTL from './TTL';
describe('TTL', () => { describe('TTL', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('key'), TTL.transformArguments('key'),
['TTL', 'key'] ['TTL', 'key']
); );
}); });
testUtils.testWithClient('client.ttl', async client => { testUtils.testAll('ttl', async client => {
assert.equal( console.log(await client.get('key'), await client.ttl('key'));
await client.ttl('key'), assert.equal(
-2 await client.ttl('key'),
); -2
}, GLOBAL.SERVERS.OPEN); );
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
}); });

View File

@@ -1,19 +1,22 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './TYPE'; import TYPE from './TYPE';
describe('TYPE', () => { describe('TYPE', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('key'), TYPE.transformArguments('key'),
['TYPE', 'key'] ['TYPE', 'key']
); );
}); });
testUtils.testWithClient('client.type', async client => { testUtils.testAll('type', async client => {
assert.equal( assert.equal(
await client.type('key'), await client.type('key'),
'none' 'none'
); );
}, GLOBAL.SERVERS.OPEN); }, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
}); });

View File

@@ -1,28 +1,31 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './UNLINK'; import UNLINK from './UNLINK';
describe('UNLINK', () => { describe('UNLINK', () => {
describe('transformArguments', () => { describe('transformArguments', () => {
it('string', () => { it('string', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('key'), UNLINK.transformArguments('key'),
['UNLINK', 'key'] ['UNLINK', 'key']
); );
});
it('array', () => {
assert.deepEqual(
transformArguments(['1', '2']),
['UNLINK', '1', '2']
);
});
}); });
testUtils.testWithClient('client.unlink', async client => { it('array', () => {
assert.equal( assert.deepEqual(
await client.unlink('key'), UNLINK.transformArguments(['1', '2']),
0 ['UNLINK', '1', '2']
); );
}, GLOBAL.SERVERS.OPEN); });
});
testUtils.testAll('unlink', async client => {
assert.equal(
await client.unlink('key'),
0
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
}); });

View File

@@ -1,19 +1,19 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './UNWATCH'; import UNWATCH from './UNWATCH';
describe('UNWATCH', () => { describe('UNWATCH', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(), UNWATCH.transformArguments(),
['UNWATCH'] ['UNWATCH']
); );
}); });
testUtils.testWithClient('client.unwatch', async client => { testUtils.testWithClient('client.unwatch', async client => {
assert.equal( assert.equal(
await client.unwatch(), await client.unwatch(),
'OK' 'OK'
); );
}, GLOBAL.SERVERS.OPEN); }, GLOBAL.SERVERS.OPEN);
}); });

View File

@@ -1,9 +1,10 @@
import { RedisArgument, SimpleStringReply, Command } from '../RESP/types'; import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
export default { export default {
FIRST_KEY_INDEX: undefined,
IS_READ_ONLY: true, IS_READ_ONLY: true,
transformArguments(key: RedisArgument) { transformArguments() {
return ['WATCH', key]; return ['UNWATCH'];
}, },
transformReply: undefined as unknown as () => SimpleStringReply transformReply: undefined as unknown as () => SimpleStringReply
} as const satisfies Command; } as const satisfies Command;

View File

@@ -1,19 +1,19 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './WAIT'; import WAIT from './WAIT';
describe('WAIT', () => { describe('WAIT', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(0, 1), WAIT.transformArguments(0, 1),
['WAIT', '0', '1'] ['WAIT', '0', '1']
); );
}); });
testUtils.testWithClient('client.wait', async client => { testUtils.testWithClient('client.wait', async client => {
assert.equal( assert.equal(
await client.wait(0, 1), await client.wait(0, 1),
0 0
); );
}, GLOBAL.SERVERS.OPEN); }, GLOBAL.SERVERS.OPEN);
}); });

View File

@@ -1,6 +1,7 @@
import { RedisArgument, SimpleStringReply, Command, NumberReply } from '../RESP/types'; import { RedisArgument, SimpleStringReply, Command, NumberReply } from '../RESP/types';
export default { export default {
FIRST_KEY_INDEX: undefined,
IS_READ_ONLY: true, IS_READ_ONLY: true,
transformArguments(numberOfReplicas: number, timeout: number) { transformArguments(numberOfReplicas: number, timeout: number) {
return ['WAIT', numberOfReplicas.toString(), timeout.toString()]; return ['WAIT', numberOfReplicas.toString(), timeout.toString()];

View File

@@ -1,20 +1,20 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import { transformArguments } from './WATCH'; import WATCH from './WATCH';
describe('WATCH', () => { describe('WATCH', () => {
describe('transformArguments', () => { describe('transformArguments', () => {
it('string', () => { it('string', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('key'), WATCH.transformArguments('key'),
['WATCH', 'key'] ['WATCH', 'key']
); );
});
it('array', () => {
assert.deepEqual(
transformArguments(['1', '2']),
['WATCH', '1', '2']
);
});
}); });
it('array', () => {
assert.deepEqual(
WATCH.transformArguments(['1', '2']),
['WATCH', '1', '2']
);
});
});
}); });

View File

@@ -2,7 +2,7 @@ import { SimpleStringReply, Command } from '../RESP/types';
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers'; import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
export default { export default {
FIRST_KEY_INDEX: 1, FIRST_KEY_INDEX: undefined,
IS_READ_ONLY: true, IS_READ_ONLY: true,
transformArguments(key: RedisVariadicArgument) { transformArguments(key: RedisVariadicArgument) {
return pushVariadicArguments(['WATCH'], key); return pushVariadicArguments(['WATCH'], key);

View File

@@ -1,28 +1,28 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XACK'; // import { transformArguments } from './XACK';
describe('XACK', () => { // describe('XACK', () => {
describe('transformArguments', () => { // describe('transformArguments', () => {
it('string', () => { // it('string', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', '1-0'), // transformArguments('key', 'group', '1-0'),
['XACK', 'key', 'group', '1-0'] // ['XACK', 'key', 'group', '1-0']
); // );
}); // });
it('array', () => { // it('array', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', ['1-0', '2-0']), // transformArguments('key', 'group', ['1-0', '2-0']),
['XACK', 'key', 'group', '1-0', '2-0'] // ['XACK', 'key', 'group', '1-0', '2-0']
); // );
}); // });
}); // });
testUtils.testWithClient('client.xAck', async client => { // testUtils.testWithClient('client.xAck', async client => {
assert.equal( // assert.equal(
await client.xAck('key', 'group', '1-0'), // await client.xAck('key', 'group', '1-0'),
0 // 0
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,118 +1,118 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XADD'; // import { transformArguments } from './XADD';
describe('XADD', () => { // describe('XADD', () => {
describe('transformArguments', () => { // describe('transformArguments', () => {
it('single field', () => { // it('single field', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', '*', { // transformArguments('key', '*', {
field: 'value' // field: 'value'
}), // }),
['XADD', 'key', '*', 'field', 'value'] // ['XADD', 'key', '*', 'field', 'value']
); // );
}); // });
it('multiple fields', () => { // it('multiple fields', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', '*', { // transformArguments('key', '*', {
'1': 'I', // '1': 'I',
'2': 'II' // '2': 'II'
}), // }),
['XADD', 'key', '*', '1', 'I', '2', 'II'] // ['XADD', 'key', '*', '1', 'I', '2', 'II']
); // );
}); // });
it('with NOMKSTREAM', () => { // it('with NOMKSTREAM', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', '*', { // transformArguments('key', '*', {
field: 'value' // field: 'value'
}, { // }, {
NOMKSTREAM: true // NOMKSTREAM: true
}), // }),
['XADD', 'key', 'NOMKSTREAM', '*', 'field', 'value'] // ['XADD', 'key', 'NOMKSTREAM', '*', 'field', 'value']
); // );
}); // });
it('with TRIM', () => { // it('with TRIM', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', '*', { // transformArguments('key', '*', {
field: 'value' // field: 'value'
}, { // }, {
TRIM: { // TRIM: {
threshold: 1000 // threshold: 1000
} // }
}), // }),
['XADD', 'key', '1000', '*', 'field', 'value'] // ['XADD', 'key', '1000', '*', 'field', 'value']
); // );
}); // });
it('with TRIM.strategy', () => { // it('with TRIM.strategy', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', '*', { // transformArguments('key', '*', {
field: 'value' // field: 'value'
}, { // }, {
TRIM: { // TRIM: {
strategy: 'MAXLEN', // strategy: 'MAXLEN',
threshold: 1000 // threshold: 1000
} // }
}), // }),
['XADD', 'key', 'MAXLEN', '1000', '*','field', 'value'] // ['XADD', 'key', 'MAXLEN', '1000', '*','field', 'value']
); // );
}); // });
it('with TRIM.strategyModifier', () => { // it('with TRIM.strategyModifier', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', '*', { // transformArguments('key', '*', {
field: 'value' // field: 'value'
}, { // }, {
TRIM: { // TRIM: {
strategyModifier: '=', // strategyModifier: '=',
threshold: 1000 // threshold: 1000
} // }
}), // }),
['XADD', 'key', '=', '1000', '*', 'field', 'value'] // ['XADD', 'key', '=', '1000', '*', 'field', 'value']
); // );
}); // });
it('with TRIM.limit', () => { // it('with TRIM.limit', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', '*', { // transformArguments('key', '*', {
field: 'value' // field: 'value'
}, { // }, {
TRIM: { // TRIM: {
threshold: 1000, // threshold: 1000,
limit: 1 // limit: 1
} // }
}), // }),
['XADD', 'key', '1000', 'LIMIT', '1', '*', 'field', 'value'] // ['XADD', 'key', '1000', 'LIMIT', '1', '*', 'field', 'value']
); // );
}); // });
it('with NOMKSTREAM, TRIM, TRIM.*', () => { // it('with NOMKSTREAM, TRIM, TRIM.*', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', '*', { // transformArguments('key', '*', {
field: 'value' // field: 'value'
}, { // }, {
NOMKSTREAM: true, // NOMKSTREAM: true,
TRIM: { // TRIM: {
strategy: 'MAXLEN', // strategy: 'MAXLEN',
strategyModifier: '=', // strategyModifier: '=',
threshold: 1000, // threshold: 1000,
limit: 1 // limit: 1
} // }
}), // }),
['XADD', 'key', 'NOMKSTREAM', 'MAXLEN', '=', '1000', 'LIMIT', '1', '*', 'field', 'value'] // ['XADD', 'key', 'NOMKSTREAM', 'MAXLEN', '=', '1000', 'LIMIT', '1', '*', 'field', 'value']
); // );
}); // });
}); // });
testUtils.testWithClient('client.xAdd', async client => { // testUtils.testWithClient('client.xAdd', async client => {
assert.equal( // assert.equal(
typeof await client.xAdd('key', '*', { // typeof await client.xAdd('key', '*', {
field: 'value' // field: 'value'
}), // }),
'string' // 'string'
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,42 +1,42 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XAUTOCLAIM'; // import { transformArguments } from './XAUTOCLAIM';
describe('XAUTOCLAIM', () => { // describe('XAUTOCLAIM', () => {
testUtils.isVersionGreaterThanHook([6, 2]); // testUtils.isVersionGreaterThanHook([6, 2]);
describe('transformArguments', () => { // describe('transformArguments', () => {
it('simple', () => { // it('simple', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', 'consumer', 1, '0-0'), // transformArguments('key', 'group', 'consumer', 1, '0-0'),
['XAUTOCLAIM', 'key', 'group', 'consumer', '1', '0-0'] // ['XAUTOCLAIM', 'key', 'group', 'consumer', '1', '0-0']
); // );
}); // });
it('with COUNT', () => { // it('with COUNT', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', 'consumer', 1, '0-0', { // transformArguments('key', 'group', 'consumer', 1, '0-0', {
COUNT: 1 // COUNT: 1
}), // }),
['XAUTOCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'COUNT', '1'] // ['XAUTOCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'COUNT', '1']
); // );
}); // });
}); // });
testUtils.testWithClient('client.xAutoClaim', async client => { // testUtils.testWithClient('client.xAutoClaim', async client => {
await Promise.all([ // await Promise.all([
client.xGroupCreate('key', 'group', '$', { // client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}), // }),
client.xGroupCreateConsumer('key', 'group', 'consumer'), // client.xGroupCreateConsumer('key', 'group', 'consumer'),
]); // ]);
assert.deepEqual( // assert.deepEqual(
await client.xAutoClaim('key', 'group', 'consumer', 1, '0-0'), // await client.xAutoClaim('key', 'group', 'consumer', 1, '0-0'),
{ // {
nextId: '0-0', // nextId: '0-0',
messages: [] // messages: []
} // }
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,31 +1,31 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XAUTOCLAIM_JUSTID'; // import { transformArguments } from './XAUTOCLAIM_JUSTID';
describe('XAUTOCLAIM JUSTID', () => { // describe('XAUTOCLAIM JUSTID', () => {
testUtils.isVersionGreaterThanHook([6, 2]); // testUtils.isVersionGreaterThanHook([6, 2]);
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', 'consumer', 1, '0-0'), // transformArguments('key', 'group', 'consumer', 1, '0-0'),
['XAUTOCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'JUSTID'] // ['XAUTOCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'JUSTID']
); // );
}); // });
testUtils.testWithClient('client.xAutoClaimJustId', async client => { // testUtils.testWithClient('client.xAutoClaimJustId', async client => {
await Promise.all([ // await Promise.all([
client.xGroupCreate('key', 'group', '$', { // client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}), // }),
client.xGroupCreateConsumer('key', 'group', 'consumer'), // client.xGroupCreateConsumer('key', 'group', 'consumer'),
]); // ]);
assert.deepEqual( // assert.deepEqual(
await client.xAutoClaimJustId('key', 'group', 'consumer', 1, '0-0'), // await client.xAutoClaimJustId('key', 'group', 'consumer', 1, '0-0'),
{ // {
nextId: '0-0', // nextId: '0-0',
messages: [] // messages: []
} // }
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,90 +1,90 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XCLAIM'; // import { transformArguments } from './XCLAIM';
describe('XCLAIM', () => { // describe('XCLAIM', () => {
describe('transformArguments', () => { // describe('transformArguments', () => {
it('single id (string)', () => { // it('single id (string)', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', 'consumer', 1, '0-0'), // transformArguments('key', 'group', 'consumer', 1, '0-0'),
['XCLAIM', 'key', 'group', 'consumer', '1', '0-0'] // ['XCLAIM', 'key', 'group', 'consumer', '1', '0-0']
); // );
}); // });
it('multiple ids (array)', () => { // it('multiple ids (array)', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', 'consumer', 1, ['0-0', '1-0']), // transformArguments('key', 'group', 'consumer', 1, ['0-0', '1-0']),
['XCLAIM', 'key', 'group', 'consumer', '1', '0-0', '1-0'] // ['XCLAIM', 'key', 'group', 'consumer', '1', '0-0', '1-0']
); // );
}); // });
it('with IDLE', () => { // it('with IDLE', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', 'consumer', 1, '0-0', { // transformArguments('key', 'group', 'consumer', 1, '0-0', {
IDLE: 1 // IDLE: 1
}), // }),
['XCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'IDLE', '1'] // ['XCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'IDLE', '1']
); // );
}); // });
it('with TIME (number)', () => { // it('with TIME (number)', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', 'consumer', 1, '0-0', { // transformArguments('key', 'group', 'consumer', 1, '0-0', {
TIME: 1 // TIME: 1
}), // }),
['XCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'TIME', '1'] // ['XCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'TIME', '1']
); // );
}); // });
it('with TIME (date)', () => { // it('with TIME (date)', () => {
const d = new Date(); // const d = new Date();
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', 'consumer', 1, '0-0', { // transformArguments('key', 'group', 'consumer', 1, '0-0', {
TIME: d // TIME: d
}), // }),
['XCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'TIME', d.getTime().toString()] // ['XCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'TIME', d.getTime().toString()]
); // );
}); // });
it('with RETRYCOUNT', () => { // it('with RETRYCOUNT', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', 'consumer', 1, '0-0', { // transformArguments('key', 'group', 'consumer', 1, '0-0', {
RETRYCOUNT: 1 // RETRYCOUNT: 1
}), // }),
['XCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'RETRYCOUNT', '1'] // ['XCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'RETRYCOUNT', '1']
); // );
}); // });
it('with FORCE', () => { // it('with FORCE', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', 'consumer', 1, '0-0', { // transformArguments('key', 'group', 'consumer', 1, '0-0', {
FORCE: true // FORCE: true
}), // }),
['XCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'FORCE'] // ['XCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'FORCE']
); // );
}); // });
it('with IDLE, TIME, RETRYCOUNT, FORCE, JUSTID', () => { // it('with IDLE, TIME, RETRYCOUNT, FORCE, JUSTID', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', 'consumer', 1, '0-0', { // transformArguments('key', 'group', 'consumer', 1, '0-0', {
IDLE: 1, // IDLE: 1,
TIME: 1, // TIME: 1,
RETRYCOUNT: 1, // RETRYCOUNT: 1,
FORCE: true // FORCE: true
}), // }),
['XCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'IDLE', '1', 'TIME', '1', 'RETRYCOUNT', '1', 'FORCE'] // ['XCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'IDLE', '1', 'TIME', '1', 'RETRYCOUNT', '1', 'FORCE']
); // );
}); // });
}); // });
testUtils.testWithClient('client.xClaim', async client => { // testUtils.testWithClient('client.xClaim', async client => {
await client.xGroupCreate('key', 'group', '$', { // await client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}); // });
assert.deepEqual( // assert.deepEqual(
await client.xClaim('key', 'group', 'consumer', 1, '0-0'), // await client.xClaim('key', 'group', 'consumer', 1, '0-0'),
[] // []
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,23 +1,23 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XCLAIM_JUSTID'; // import { transformArguments } from './XCLAIM_JUSTID';
describe('XCLAIM JUSTID', () => { // describe('XCLAIM JUSTID', () => {
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', 'consumer', 1, '0-0'), // transformArguments('key', 'group', 'consumer', 1, '0-0'),
['XCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'JUSTID'] // ['XCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'JUSTID']
); // );
}); // });
testUtils.testWithClient('client.xClaimJustId', async client => { // testUtils.testWithClient('client.xClaimJustId', async client => {
await client.xGroupCreate('key', 'group', '$', { // await client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}); // });
assert.deepEqual( // assert.deepEqual(
await client.xClaimJustId('key', 'group', 'consumer', 1, '0-0'), // await client.xClaimJustId('key', 'group', 'consumer', 1, '0-0'),
[] // []
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,28 +1,28 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XDEL'; // import { transformArguments } from './XDEL';
describe('XDEL', () => { // describe('XDEL', () => {
describe('transformArguments', () => { // describe('transformArguments', () => {
it('string', () => { // it('string', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', '0-0'), // transformArguments('key', '0-0'),
['XDEL', 'key', '0-0'] // ['XDEL', 'key', '0-0']
); // );
}); // });
it('array', () => { // it('array', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', ['0-0', '1-0']), // transformArguments('key', ['0-0', '1-0']),
['XDEL', 'key', '0-0', '1-0'] // ['XDEL', 'key', '0-0', '1-0']
); // );
}); // });
}); // });
testUtils.testWithClient('client.xDel', async client => { // testUtils.testWithClient('client.xDel', async client => {
assert.equal( // assert.equal(
await client.xDel('key', '0-0'), // await client.xDel('key', '0-0'),
0 // 0
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,32 +1,32 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XGROUP_CREATE'; // import { transformArguments } from './XGROUP_CREATE';
describe('XGROUP CREATE', () => { // describe('XGROUP CREATE', () => {
describe('transformArguments', () => { // describe('transformArguments', () => {
it('simple', () => { // it('simple', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', '$'), // transformArguments('key', 'group', '$'),
['XGROUP', 'CREATE', 'key', 'group', '$'] // ['XGROUP', 'CREATE', 'key', 'group', '$']
); // );
}); // });
it('with MKSTREAM', () => { // it('with MKSTREAM', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', '$', { // transformArguments('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}), // }),
['XGROUP', 'CREATE', 'key', 'group', '$', 'MKSTREAM'] // ['XGROUP', 'CREATE', 'key', 'group', '$', 'MKSTREAM']
); // );
}); // });
}); // });
testUtils.testWithClient('client.xGroupCreate', async client => { // testUtils.testWithClient('client.xGroupCreate', async client => {
assert.equal( // assert.equal(
await client.xGroupCreate('key', 'group', '$', { // await client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}), // }),
'OK' // 'OK'
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,25 +1,25 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XGROUP_CREATECONSUMER'; // import { transformArguments } from './XGROUP_CREATECONSUMER';
describe('XGROUP CREATECONSUMER', () => { // describe('XGROUP CREATECONSUMER', () => {
testUtils.isVersionGreaterThanHook([6, 2]); // testUtils.isVersionGreaterThanHook([6, 2]);
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', 'consumer'), // transformArguments('key', 'group', 'consumer'),
['XGROUP', 'CREATECONSUMER', 'key', 'group', 'consumer'] // ['XGROUP', 'CREATECONSUMER', 'key', 'group', 'consumer']
); // );
}); // });
testUtils.testWithClient('client.xGroupCreateConsumer', async client => { // testUtils.testWithClient('client.xGroupCreateConsumer', async client => {
await client.xGroupCreate('key', 'group', '$', { // await client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}); // });
assert.equal( // assert.equal(
await client.xGroupCreateConsumer('key', 'group', 'consumer'), // await client.xGroupCreateConsumer('key', 'group', 'consumer'),
true // true
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,23 +1,23 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XGROUP_DELCONSUMER'; // import { transformArguments } from './XGROUP_DELCONSUMER';
describe('XGROUP DELCONSUMER', () => { // describe('XGROUP DELCONSUMER', () => {
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', 'consumer'), // transformArguments('key', 'group', 'consumer'),
['XGROUP', 'DELCONSUMER', 'key', 'group', 'consumer'] // ['XGROUP', 'DELCONSUMER', 'key', 'group', 'consumer']
); // );
}); // });
testUtils.testWithClient('client.xGroupDelConsumer', async client => { // testUtils.testWithClient('client.xGroupDelConsumer', async client => {
await client.xGroupCreate('key', 'group', '$', { // await client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}); // });
assert.equal( // assert.equal(
await client.xGroupDelConsumer('key', 'group', 'consumer'), // await client.xGroupDelConsumer('key', 'group', 'consumer'),
0 // 0
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,23 +1,23 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XGROUP_DESTROY'; // import { transformArguments } from './XGROUP_DESTROY';
describe('XGROUP DESTROY', () => { // describe('XGROUP DESTROY', () => {
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group'), // transformArguments('key', 'group'),
['XGROUP', 'DESTROY', 'key', 'group'] // ['XGROUP', 'DESTROY', 'key', 'group']
); // );
}); // });
testUtils.testWithClient('client.xGroupDestroy', async client => { // testUtils.testWithClient('client.xGroupDestroy', async client => {
await client.xGroupCreate('key', 'group', '$', { // await client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}); // });
assert.equal( // assert.equal(
await client.xGroupDestroy('key', 'group'), // await client.xGroupDestroy('key', 'group'),
true // true
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,23 +1,23 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XGROUP_SETID'; // import { transformArguments } from './XGROUP_SETID';
describe('XGROUP SETID', () => { // describe('XGROUP SETID', () => {
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', '0'), // transformArguments('key', 'group', '0'),
['XGROUP', 'SETID', 'key', 'group', '0'] // ['XGROUP', 'SETID', 'key', 'group', '0']
); // );
}); // });
testUtils.testWithClient('client.xGroupSetId', async client => { // testUtils.testWithClient('client.xGroupSetId', async client => {
await client.xGroupCreate('key', 'group', '$', { // await client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}); // });
assert.equal( // assert.equal(
await client.xGroupSetId('key', 'group', '0'), // await client.xGroupSetId('key', 'group', '0'),
'OK' // 'OK'
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,41 +1,41 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './XINFO_CONSUMERS'; // import { transformArguments, transformReply } from './XINFO_CONSUMERS';
describe('XINFO CONSUMERS', () => { // describe('XINFO CONSUMERS', () => {
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group'), // transformArguments('key', 'group'),
['XINFO', 'CONSUMERS', 'key', 'group'] // ['XINFO', 'CONSUMERS', 'key', 'group']
); // );
}); // });
it('transformReply', () => { // it('transformReply', () => {
assert.deepEqual( // assert.deepEqual(
transformReply([ // transformReply([
['name', 'Alice', 'pending', 1, 'idle', 9104628], // ['name', 'Alice', 'pending', 1, 'idle', 9104628],
['name', 'Bob', 'pending', 1, 'idle', 83841983] // ['name', 'Bob', 'pending', 1, 'idle', 83841983]
]), // ]),
[{ // [{
name: 'Alice', // name: 'Alice',
pending: 1, // pending: 1,
idle: 9104628 // idle: 9104628
}, { // }, {
name: 'Bob', // name: 'Bob',
pending: 1, // pending: 1,
idle: 83841983 // idle: 83841983
}] // }]
); // );
}); // });
testUtils.testWithClient('client.xInfoConsumers', async client => { // testUtils.testWithClient('client.xInfoConsumers', async client => {
await client.xGroupCreate('key', 'group', '$', { // await client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}); // });
assert.deepEqual( // assert.deepEqual(
await client.xInfoConsumers('key', 'group'), // await client.xInfoConsumers('key', 'group'),
[] // []
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,48 +1,48 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './XINFO_GROUPS'; // import { transformArguments, transformReply } from './XINFO_GROUPS';
describe('XINFO GROUPS', () => { // describe('XINFO GROUPS', () => {
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key'), // transformArguments('key'),
['XINFO', 'GROUPS', 'key'] // ['XINFO', 'GROUPS', 'key']
); // );
}); // });
it('transformReply', () => { // it('transformReply', () => {
assert.deepEqual( // assert.deepEqual(
transformReply([ // transformReply([
['name', 'mygroup', 'consumers', 2, 'pending', 2, 'last-delivered-id', '1588152489012-0'], // ['name', 'mygroup', 'consumers', 2, 'pending', 2, 'last-delivered-id', '1588152489012-0'],
['name', 'some-other-group', 'consumers', 1, 'pending', 0, 'last-delivered-id', '1588152498034-0'] // ['name', 'some-other-group', 'consumers', 1, 'pending', 0, 'last-delivered-id', '1588152498034-0']
]), // ]),
[{ // [{
name: 'mygroup', // name: 'mygroup',
consumers: 2, // consumers: 2,
pending: 2, // pending: 2,
lastDeliveredId: '1588152489012-0' // lastDeliveredId: '1588152489012-0'
}, { // }, {
name: 'some-other-group', // name: 'some-other-group',
consumers: 1, // consumers: 1,
pending: 0, // pending: 0,
lastDeliveredId: '1588152498034-0' // lastDeliveredId: '1588152498034-0'
}] // }]
); // );
}); // });
testUtils.testWithClient('client.xInfoGroups', async client => { // testUtils.testWithClient('client.xInfoGroups', async client => {
await client.xGroupCreate('key', 'group', '$', { // await client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}); // });
assert.deepEqual( // assert.deepEqual(
await client.xInfoGroups('key'), // await client.xInfoGroups('key'),
[{ // [{
name: 'group', // name: 'group',
consumers: 0, // consumers: 0,
pending: 0, // pending: 0,
lastDeliveredId: '0-0' // lastDeliveredId: '0-0'
}] // }]
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,72 +1,72 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './XINFO_STREAM'; // import { transformArguments, transformReply } from './XINFO_STREAM';
describe('XINFO STREAM', () => { // describe('XINFO STREAM', () => {
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key'), // transformArguments('key'),
['XINFO', 'STREAM', 'key'] // ['XINFO', 'STREAM', 'key']
); // );
}); // });
it('transformReply', () => { // it('transformReply', () => {
assert.deepEqual( // assert.deepEqual(
transformReply([ // transformReply([
'length', 2, // 'length', 2,
'radix-tree-keys', 1, // 'radix-tree-keys', 1,
'radix-tree-nodes', 2, // 'radix-tree-nodes', 2,
'last-generated-id', '1538385846314-0', // 'last-generated-id', '1538385846314-0',
'groups', 2, // 'groups', 2,
'first-entry', ['1538385820729-0', ['foo', 'bar']], // 'first-entry', ['1538385820729-0', ['foo', 'bar']],
'last-entry', ['1538385846314-0', ['field', 'value']] // 'last-entry', ['1538385846314-0', ['field', 'value']]
]), // ]),
{ // {
length: 2, // length: 2,
radixTreeKeys: 1, // radixTreeKeys: 1,
radixTreeNodes: 2, // radixTreeNodes: 2,
groups: 2, // groups: 2,
lastGeneratedId: '1538385846314-0', // lastGeneratedId: '1538385846314-0',
firstEntry: { // firstEntry: {
id: '1538385820729-0', // id: '1538385820729-0',
message: Object.create(null, { // message: Object.create(null, {
foo: { // foo: {
value: 'bar', // value: 'bar',
configurable: true, // configurable: true,
enumerable: true // enumerable: true
} // }
}) // })
}, // },
lastEntry: { // lastEntry: {
id: '1538385846314-0', // id: '1538385846314-0',
message: Object.create(null, { // message: Object.create(null, {
field: { // field: {
value: 'value', // value: 'value',
configurable: true, // configurable: true,
enumerable: true // enumerable: true
} // }
}) // })
} // }
} // }
); // );
}); // });
testUtils.testWithClient('client.xInfoStream', async client => { // testUtils.testWithClient('client.xInfoStream', async client => {
await client.xGroupCreate('key', 'group', '$', { // await client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}); // });
assert.deepEqual( // assert.deepEqual(
await client.xInfoStream('key'), // await client.xInfoStream('key'),
{ // {
length: 0, // length: 0,
radixTreeKeys: 0, // radixTreeKeys: 0,
radixTreeNodes: 1, // radixTreeNodes: 1,
groups: 1, // groups: 1,
lastGeneratedId: '0-0', // lastGeneratedId: '0-0',
firstEntry: null, // firstEntry: null,
lastEntry: null // lastEntry: null
} // }
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,19 +1,22 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XLEN'; import XLEN from './XLEN';
describe('XLEN', () => { describe('XLEN', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('key'), XLEN.transformArguments('key'),
['XLEN', 'key'] ['XLEN', 'key']
); );
}); });
testUtils.testWithClient('client.xLen', async client => { testUtils.testAll('xLen', async client => {
assert.equal( assert.equal(
await client.xLen('key'), await client.xLen('key'),
0 0
); );
}, GLOBAL.SERVERS.OPEN); }, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
}); });

View File

@@ -1,62 +1,62 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XPENDING'; // import { transformArguments } from './XPENDING';
describe('XPENDING', () => { // describe('XPENDING', () => {
describe('transformArguments', () => { // describe('transformArguments', () => {
it('transformArguments', () => { // it('transformArguments', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group'), // transformArguments('key', 'group'),
['XPENDING', 'key', 'group'] // ['XPENDING', 'key', 'group']
); // );
}); // });
}); // });
describe('client.xPending', () => { // describe('client.xPending', () => {
testUtils.testWithClient('simple', async client => { // testUtils.testWithClient('simple', async client => {
await client.xGroupCreate('key', 'group', '$', { // await client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}); // });
assert.deepEqual( // assert.deepEqual(
await client.xPending('key', 'group'), // await client.xPending('key', 'group'),
{ // {
pending: 0, // pending: 0,
firstId: null, // firstId: null,
lastId: null, // lastId: null,
consumers: null // consumers: null
} // }
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('with consumers', async client => { // testUtils.testWithClient('with consumers', async client => {
const [,, id] = await Promise.all([ // const [,, id] = await Promise.all([
client.xGroupCreate('key', 'group', '$', { // client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}), // }),
client.xGroupCreateConsumer('key', 'group', 'consumer'), // client.xGroupCreateConsumer('key', 'group', 'consumer'),
client.xAdd('key', '*', { field: 'value' }), // client.xAdd('key', '*', { field: 'value' }),
client.xReadGroup('group', 'consumer', { // client.xReadGroup('group', 'consumer', {
key: 'key', // key: 'key',
id: '>' // id: '>'
}) // })
]); // ]);
assert.deepEqual( // assert.deepEqual(
await client.xPending('key', 'group'), // await client.xPending('key', 'group'),
{ // {
pending: 1, // pending: 1,
firstId: id, // firstId: id,
lastId: id, // lastId: id,
consumers: [{ // consumers: [{
name: 'consumer', // name: 'consumer',
deliveriesCounter: 1 // deliveriesCounter: 1
}] // }]
} // }
); // );
}, { // }, {
...GLOBAL.SERVERS.OPEN, // ...GLOBAL.SERVERS.OPEN,
minimumDockerVersion: [6, 2] // minimumDockerVersion: [6, 2]
}); // });
}); // });
}); // });

View File

@@ -1,53 +1,53 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XPENDING_RANGE'; // import { transformArguments } from './XPENDING_RANGE';
describe('XPENDING RANGE', () => { // describe('XPENDING RANGE', () => {
describe('transformArguments', () => { // describe('transformArguments', () => {
it('simple', () => { // it('simple', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', '-', '+', 1), // transformArguments('key', 'group', '-', '+', 1),
['XPENDING', 'key', 'group', '-', '+', '1'] // ['XPENDING', 'key', 'group', '-', '+', '1']
); // );
}); // });
it('with IDLE', () => { // it('with IDLE', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', '-', '+', 1, { // transformArguments('key', 'group', '-', '+', 1, {
IDLE: 1, // IDLE: 1,
}), // }),
['XPENDING', 'key', 'group', 'IDLE', '1', '-', '+', '1'] // ['XPENDING', 'key', 'group', 'IDLE', '1', '-', '+', '1']
); // );
}); // });
it('with consumer', () => { // it('with consumer', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', '-', '+', 1, { // transformArguments('key', 'group', '-', '+', 1, {
consumer: 'consumer' // consumer: 'consumer'
}), // }),
['XPENDING', 'key', 'group', '-', '+', '1', 'consumer'] // ['XPENDING', 'key', 'group', '-', '+', '1', 'consumer']
); // );
}); // });
it('with IDLE, consumer', () => { // it('with IDLE, consumer', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'group', '-', '+', 1, { // transformArguments('key', 'group', '-', '+', 1, {
IDLE: 1, // IDLE: 1,
consumer: 'consumer' // consumer: 'consumer'
}), // }),
['XPENDING', 'key', 'group', 'IDLE', '1', '-', '+', '1', 'consumer'] // ['XPENDING', 'key', 'group', 'IDLE', '1', '-', '+', '1', 'consumer']
); // );
}); // });
}); // });
testUtils.testWithClient('client.xPendingRange', async client => { // testUtils.testWithClient('client.xPendingRange', async client => {
await client.xGroupCreate('key', 'group', '$', { // await client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}); // });
assert.deepEqual( // assert.deepEqual(
await client.xPendingRange('key', 'group', '-', '+', 1), // await client.xPendingRange('key', 'group', '-', '+', 1),
[] // []
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,30 +1,30 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XRANGE'; // import { transformArguments } from './XRANGE';
describe('XRANGE', () => { // describe('XRANGE', () => {
describe('transformArguments', () => { // describe('transformArguments', () => {
it('simple', () => { // it('simple', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', '-', '+'), // transformArguments('key', '-', '+'),
['XRANGE', 'key', '-', '+'] // ['XRANGE', 'key', '-', '+']
); // );
}); // });
it('with COUNT', () => { // it('with COUNT', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', '-', '+', { // transformArguments('key', '-', '+', {
COUNT: 1 // COUNT: 1
}), // }),
['XRANGE', 'key', '-', '+', 'COUNT', '1'] // ['XRANGE', 'key', '-', '+', 'COUNT', '1']
); // );
}); // });
}); // });
testUtils.testWithClient('client.xRange', async client => { // testUtils.testWithClient('client.xRange', async client => {
assert.deepEqual( // assert.deepEqual(
await client.xRange('key', '+', '-'), // await client.xRange('key', '+', '-'),
[] // []
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,103 +1,103 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { FIRST_KEY_INDEX, transformArguments } from './XREAD'; // import { FIRST_KEY_INDEX, transformArguments } from './XREAD';
describe('XREAD', () => { // describe('XREAD', () => {
describe('FIRST_KEY_INDEX', () => { // describe('FIRST_KEY_INDEX', () => {
it('single stream', () => { // it('single stream', () => {
assert.equal( // assert.equal(
FIRST_KEY_INDEX({ key: 'key', id: '' }), // FIRST_KEY_INDEX({ key: 'key', id: '' }),
'key' // 'key'
); // );
}); // });
it('multiple streams', () => { // it('multiple streams', () => {
assert.equal( // assert.equal(
FIRST_KEY_INDEX([{ key: '1', id: '' }, { key: '2', id: '' }]), // FIRST_KEY_INDEX([{ key: '1', id: '' }, { key: '2', id: '' }]),
'1' // '1'
); // );
}); // });
}); // });
describe('transformArguments', () => { // describe('transformArguments', () => {
it('single stream', () => { // it('single stream', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments({ // transformArguments({
key: 'key', // key: 'key',
id: '0' // id: '0'
}), // }),
['XREAD', 'STREAMS', 'key', '0'] // ['XREAD', 'STREAMS', 'key', '0']
); // );
}); // });
it('multiple streams', () => { // it('multiple streams', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments([{ // transformArguments([{
key: '1', // key: '1',
id: '0' // id: '0'
}, { // }, {
key: '2', // key: '2',
id: '0' // id: '0'
}]), // }]),
['XREAD', 'STREAMS', '1', '2', '0', '0'] // ['XREAD', 'STREAMS', '1', '2', '0', '0']
); // );
}); // });
it('with COUNT', () => { // it('with COUNT', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments({ // transformArguments({
key: 'key', // key: 'key',
id: '0' // id: '0'
}, { // }, {
COUNT: 1 // COUNT: 1
}), // }),
['XREAD', 'COUNT', '1', 'STREAMS', 'key', '0'] // ['XREAD', 'COUNT', '1', 'STREAMS', 'key', '0']
); // );
}); // });
it('with BLOCK', () => { // it('with BLOCK', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments({ // transformArguments({
key: 'key', // key: 'key',
id: '0' // id: '0'
}, { // }, {
BLOCK: 0 // BLOCK: 0
}), // }),
['XREAD', 'BLOCK', '0', 'STREAMS', 'key', '0'] // ['XREAD', 'BLOCK', '0', 'STREAMS', 'key', '0']
); // );
}); // });
it('with COUNT, BLOCK', () => { // it('with COUNT, BLOCK', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments({ // transformArguments({
key: 'key', // key: 'key',
id: '0' // id: '0'
}, { // }, {
COUNT: 1, // COUNT: 1,
BLOCK: 0 // BLOCK: 0
}), // }),
['XREAD', 'COUNT', '1', 'BLOCK', '0', 'STREAMS', 'key', '0'] // ['XREAD', 'COUNT', '1', 'BLOCK', '0', 'STREAMS', 'key', '0']
); // );
}); // });
}); // });
testUtils.testWithClient('client.xRead', async client => { // testUtils.testWithClient('client.xRead', async client => {
assert.equal( // assert.equal(
await client.xRead({ // await client.xRead({
key: 'key', // key: 'key',
id: '0' // id: '0'
}), // }),
null // null
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.xRead', async cluster => { // testUtils.testWithCluster('cluster.xRead', async cluster => {
assert.equal( // assert.equal(
await cluster.xRead({ // await cluster.xRead({
key: 'key', // key: 'key',
id: '0' // id: '0'
}), // }),
null // null
); // );
}, GLOBAL.CLUSTERS.OPEN); // }, GLOBAL.CLUSTERS.OPEN);
}); // });

View File

@@ -1,153 +1,153 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { FIRST_KEY_INDEX, transformArguments } from './XREADGROUP'; // import { FIRST_KEY_INDEX, transformArguments } from './XREADGROUP';
describe('XREADGROUP', () => { // describe('XREADGROUP', () => {
describe('FIRST_KEY_INDEX', () => { // describe('FIRST_KEY_INDEX', () => {
it('single stream', () => { // it('single stream', () => {
assert.equal( // assert.equal(
FIRST_KEY_INDEX('', '', { key: 'key', id: '' }), // FIRST_KEY_INDEX('', '', { key: 'key', id: '' }),
'key' // 'key'
); // );
}); // });
it('multiple streams', () => { // it('multiple streams', () => {
assert.equal( // assert.equal(
FIRST_KEY_INDEX('', '', [{ key: '1', id: '' }, { key: '2', id: '' }]), // FIRST_KEY_INDEX('', '', [{ key: '1', id: '' }, { key: '2', id: '' }]),
'1' // '1'
); // );
}); // });
}); // });
describe('transformArguments', () => { // describe('transformArguments', () => {
it('single stream', () => { // it('single stream', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('group', 'consumer', { // transformArguments('group', 'consumer', {
key: 'key', // key: 'key',
id: '0' // id: '0'
}), // }),
['XREADGROUP', 'GROUP', 'group', 'consumer', 'STREAMS', 'key', '0'] // ['XREADGROUP', 'GROUP', 'group', 'consumer', 'STREAMS', 'key', '0']
); // );
}); // });
it('multiple streams', () => { // it('multiple streams', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('group', 'consumer', [{ // transformArguments('group', 'consumer', [{
key: '1', // key: '1',
id: '0' // id: '0'
}, { // }, {
key: '2', // key: '2',
id: '0' // id: '0'
}]), // }]),
['XREADGROUP', 'GROUP', 'group', 'consumer', 'STREAMS', '1', '2', '0', '0'] // ['XREADGROUP', 'GROUP', 'group', 'consumer', 'STREAMS', '1', '2', '0', '0']
); // );
}); // });
it('with COUNT', () => { // it('with COUNT', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('group', 'consumer', { // transformArguments('group', 'consumer', {
key: 'key', // key: 'key',
id: '0' // id: '0'
}, { // }, {
COUNT: 1 // COUNT: 1
}), // }),
['XREADGROUP', 'GROUP', 'group', 'consumer', 'COUNT', '1', 'STREAMS', 'key', '0'] // ['XREADGROUP', 'GROUP', 'group', 'consumer', 'COUNT', '1', 'STREAMS', 'key', '0']
); // );
}); // });
it('with BLOCK', () => { // it('with BLOCK', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('group', 'consumer', { // transformArguments('group', 'consumer', {
key: 'key', // key: 'key',
id: '0' // id: '0'
}, { // }, {
BLOCK: 0 // BLOCK: 0
}), // }),
['XREADGROUP', 'GROUP', 'group', 'consumer', 'BLOCK', '0', 'STREAMS', 'key', '0'] // ['XREADGROUP', 'GROUP', 'group', 'consumer', 'BLOCK', '0', 'STREAMS', 'key', '0']
); // );
}); // });
it('with NOACK', () => { // it('with NOACK', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('group', 'consumer', { // transformArguments('group', 'consumer', {
key: 'key', // key: 'key',
id: '0' // id: '0'
}, { // }, {
NOACK: true // NOACK: true
}), // }),
['XREADGROUP', 'GROUP', 'group', 'consumer', 'NOACK', 'STREAMS', 'key', '0'] // ['XREADGROUP', 'GROUP', 'group', 'consumer', 'NOACK', 'STREAMS', 'key', '0']
); // );
}); // });
it('with COUNT, BLOCK, NOACK', () => { // it('with COUNT, BLOCK, NOACK', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('group', 'consumer', { // transformArguments('group', 'consumer', {
key: 'key', // key: 'key',
id: '0' // id: '0'
}, { // }, {
COUNT: 1, // COUNT: 1,
BLOCK: 0, // BLOCK: 0,
NOACK: true // NOACK: true
}), // }),
['XREADGROUP', 'GROUP', 'group', 'consumer', 'COUNT', '1', 'BLOCK', '0', 'NOACK', 'STREAMS', 'key', '0'] // ['XREADGROUP', 'GROUP', 'group', 'consumer', 'COUNT', '1', 'BLOCK', '0', 'NOACK', 'STREAMS', 'key', '0']
); // );
}); // });
}); // });
describe('client.xReadGroup', () => { // describe('client.xReadGroup', () => {
testUtils.testWithClient('null', async client => { // testUtils.testWithClient('null', async client => {
const [, readGroupReply] = await Promise.all([ // const [, readGroupReply] = await Promise.all([
client.xGroupCreate('key', 'group', '$', { // client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}), // }),
client.xReadGroup('group', 'consumer', { // client.xReadGroup('group', 'consumer', {
key: 'key', // key: 'key',
id: '>' // id: '>'
}) // })
]); // ]);
assert.equal(readGroupReply, null); // assert.equal(readGroupReply, null);
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('with a message', async client => { // testUtils.testWithClient('with a message', async client => {
const [, id, readGroupReply] = await Promise.all([ // const [, id, readGroupReply] = await Promise.all([
client.xGroupCreate('key', 'group', '$', { // client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}), // }),
client.xAdd('key', '*', { field: 'value' }), // client.xAdd('key', '*', { field: 'value' }),
client.xReadGroup('group', 'consumer', { // client.xReadGroup('group', 'consumer', {
key: 'key', // key: 'key',
id: '>' // id: '>'
}) // })
]); // ]);
assert.deepEqual(readGroupReply, [{ // assert.deepEqual(readGroupReply, [{
name: 'key', // name: 'key',
messages: [{ // messages: [{
id, // id,
message: Object.create(null, { // message: Object.create(null, {
field: { // field: {
value: 'value', // value: 'value',
configurable: true, // configurable: true,
enumerable: true // enumerable: true
} // }
}) // })
}] // }]
}]); // }]);
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });
testUtils.testWithCluster('cluster.xReadGroup', async cluster => { // testUtils.testWithCluster('cluster.xReadGroup', async cluster => {
const [, readGroupReply] = await Promise.all([ // const [, readGroupReply] = await Promise.all([
cluster.xGroupCreate('key', 'group', '$', { // cluster.xGroupCreate('key', 'group', '$', {
MKSTREAM: true // MKSTREAM: true
}), // }),
cluster.xReadGroup('group', 'consumer', { // cluster.xReadGroup('group', 'consumer', {
key: 'key', // key: 'key',
id: '>' // id: '>'
}) // })
]); // ]);
assert.equal(readGroupReply, null); // assert.equal(readGroupReply, null);
}, GLOBAL.CLUSTERS.OPEN); // }, GLOBAL.CLUSTERS.OPEN);
}); // });

View File

@@ -1,30 +1,30 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XREVRANGE'; // import { transformArguments } from './XREVRANGE';
describe('XREVRANGE', () => { // describe('XREVRANGE', () => {
describe('transformArguments', () => { // describe('transformArguments', () => {
it('simple', () => { // it('simple', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', '-', '+'), // transformArguments('key', '-', '+'),
['XREVRANGE', 'key', '-', '+'] // ['XREVRANGE', 'key', '-', '+']
); // );
}); // });
it('with COUNT', () => { // it('with COUNT', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', '-', '+', { // transformArguments('key', '-', '+', {
COUNT: 1 // COUNT: 1
}), // }),
['XREVRANGE', 'key', '-', '+', 'COUNT', '1'] // ['XREVRANGE', 'key', '-', '+', 'COUNT', '1']
); // );
}); // });
}); // });
testUtils.testWithClient('client.xRevRange', async client => { // testUtils.testWithClient('client.xRevRange', async client => {
assert.deepEqual( // assert.deepEqual(
await client.xRevRange('key', '+', '-'), // await client.xRevRange('key', '+', '-'),
[] // []
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -1,49 +1,49 @@
import { strict as assert } from 'assert'; // import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; // import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './XTRIM'; // import { transformArguments } from './XTRIM';
describe('XTRIM', () => { // describe('XTRIM', () => {
describe('transformArguments', () => { // describe('transformArguments', () => {
it('simple', () => { // it('simple', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'MAXLEN', 1), // transformArguments('key', 'MAXLEN', 1),
['XTRIM', 'key', 'MAXLEN', '1'] // ['XTRIM', 'key', 'MAXLEN', '1']
); // );
}); // });
it('with strategyModifier', () => { // it('with strategyModifier', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'MAXLEN', 1, { // transformArguments('key', 'MAXLEN', 1, {
strategyModifier: '=' // strategyModifier: '='
}), // }),
['XTRIM', 'key', 'MAXLEN', '=', '1'] // ['XTRIM', 'key', 'MAXLEN', '=', '1']
); // );
}); // });
it('with LIMIT', () => { // it('with LIMIT', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'MAXLEN', 1, { // transformArguments('key', 'MAXLEN', 1, {
LIMIT: 1 // LIMIT: 1
}), // }),
['XTRIM', 'key', 'MAXLEN', '1', 'LIMIT', '1'] // ['XTRIM', 'key', 'MAXLEN', '1', 'LIMIT', '1']
); // );
}); // });
it('with strategyModifier, LIMIT', () => { // it('with strategyModifier, LIMIT', () => {
assert.deepEqual( // assert.deepEqual(
transformArguments('key', 'MAXLEN', 1, { // transformArguments('key', 'MAXLEN', 1, {
strategyModifier: '=', // strategyModifier: '=',
LIMIT: 1 // LIMIT: 1
}), // }),
['XTRIM', 'key', 'MAXLEN', '=', '1', 'LIMIT', '1'] // ['XTRIM', 'key', 'MAXLEN', '=', '1', 'LIMIT', '1']
); // );
}); // });
}); // });
testUtils.testWithClient('client.xTrim', async client => { // testUtils.testWithClient('client.xTrim', async client => {
assert.equal( // assert.equal(
await client.xTrim('key', 'MAXLEN', 1), // await client.xTrim('key', 'MAXLEN', 1),
0 // 0
); // );
}, GLOBAL.SERVERS.OPEN); // }, GLOBAL.SERVERS.OPEN);
}); // });

View File

@@ -104,8 +104,20 @@ import SETEX from './SETEX';
import SETNX from './SETNX'; import SETNX from './SETNX';
import SETRANGE from './SETRANGE'; import SETRANGE from './SETRANGE';
import SMEMBERS from './SMEMBERS'; import SMEMBERS from './SMEMBERS';
import SPUBLISH from './SPUBLISH';
import SRANDMEMBER_COUNT from './SRANDMEMBER_COUNT';
import SRANDMEMBER from './SRANDMEMBER';
import SREM from './SREM';
import SSCAN from './SSCAN'; import SSCAN from './SSCAN';
import STRLEN from './STRLEN'; import STRLEN from './STRLEN';
import TOUCH from './TOUCH';
import TTL from './TTL';
import TYPE from './TYPE';
import UNLINK from './UNLINK';
import UNWATCH from './UNWATCH';
import WAIT from './WAIT';
import WATCH from './WATCH';
import XLEN from './XLEN';
import ZADD from './ZADD'; import ZADD from './ZADD';
import ZCARD from './ZCARD'; import ZCARD from './ZCARD';
import ZCOUNT from './ZCOUNT'; import ZCOUNT from './ZCOUNT';
@@ -344,10 +356,34 @@ export default {
setRange: SETRANGE, setRange: SETRANGE,
SMEMBERS, SMEMBERS,
sMembers: SMEMBERS, sMembers: SMEMBERS,
SPUBLISH,
sPublish: SPUBLISH,
SRANDMEMBER_COUNT,
sRandMemberCount: SRANDMEMBER_COUNT,
SRANDMEMBER,
sRandMember: SRANDMEMBER,
SREM,
sRem: SREM,
SSCAN, SSCAN,
sScan: SSCAN, sScan: SSCAN,
STRLEN, STRLEN,
strLen: STRLEN, strLen: STRLEN,
TOUCH,
touch: TOUCH,
TTL,
ttl: TTL,
TYPE,
type: TYPE,
UNLINK,
unlink: UNLINK,
UNWATCH,
unwatch: UNWATCH,
WAIT,
wait: WAIT,
WATCH,
watch: WATCH,
XLEN,
xLen: XLEN,
ZADD, ZADD,
zAdd: ZADD, zAdd: ZADD,
ZCARD, ZCARD,

View File

@@ -13,7 +13,7 @@ import {
createCluster, createCluster,
RedisClusterOptions, RedisClusterOptions,
RedisClusterType RedisClusterType
} from '@redis/client'; } from '@redis/client/index';
import { RedisServerDockerConfig, spawnRedisServer, spawnRedisCluster } from './dockers'; import { RedisServerDockerConfig, spawnRedisServer, spawnRedisCluster } from './dockers';
import yargs from 'yargs'; import yargs from 'yargs';
import { hideBin } from 'yargs/helpers'; import { hideBin } from 'yargs/helpers';