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) {
const cb = this._decodeUnsingedNumber.bind(this, 0);
return this._cursor === chunk.length ?
return ++this._cursor === chunk.length ?
this._decodeNumberValue.bind(isNegative, cb) :
this._decodeNumberValue(isNegative, cb, chunk);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,28 +1,31 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './SREM';
import SREM from './SREM';
describe('SREM', () => {
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
transformArguments('key', 'member'),
['SREM', 'key', 'member']
);
});
it('array', () => {
assert.deepEqual(
transformArguments('key', ['1', '2']),
['SREM', 'key', '1', '2']
);
});
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
SREM.transformArguments('key', 'member'),
['SREM', 'key', 'member']
);
});
testUtils.testWithClient('client.sRem', async client => {
assert.equal(
await client.sRem('key', 'member'),
0
);
}, GLOBAL.SERVERS.OPEN);
it('array', () => {
assert.deepEqual(
SREM.transformArguments('key', ['1', '2']),
['SREM', 'key', '1', '2']
);
});
});
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 testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './SSCAN';
import SSCAN from './SSCAN';
describe('SSCAN', () => {
describe('transformArguments', () => {
it('cusror only', () => {
assert.deepEqual(
transformArguments('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('transformArguments', () => {
it('cusror only', () => {
assert.deepEqual(
SSCAN.transformArguments('key', 0),
['SSCAN', 'key', '0']
);
});
describe('transformReply', () => {
it('without members', () => {
assert.deepEqual(
transformReply(['0', []]),
{
cursor: 0,
members: []
}
);
});
it('with members', () => {
assert.deepEqual(
transformReply(['0', ['member']]),
{
cursor: 0,
members: ['member']
}
);
});
it('with MATCH', () => {
assert.deepEqual(
SSCAN.transformArguments('key', 0, {
MATCH: 'pattern'
}),
['SSCAN', 'key', '0', 'MATCH', 'pattern']
);
});
testUtils.testWithClient('client.sScan', async client => {
assert.deepEqual(
await client.sScan('key', 0),
{
cursor: 0,
members: []
}
);
}, GLOBAL.SERVERS.OPEN);
it('with COUNT', () => {
assert.deepEqual(
SSCAN.transformArguments('key', 0, {
COUNT: 1
}),
['SSCAN', 'key', '0', 'COUNT', '1']
);
});
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 testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './STRLEN';
import STRLEN from './STRLEN';
describe('STRLEN', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key'),
['STRLEN', 'key']
);
});
it('transformArguments', () => {
assert.deepEqual(
STRLEN.transformArguments('key'),
['STRLEN', 'key']
);
});
testUtils.testWithClient('client.strLen', async client => {
assert.equal(
await client.strLen('key'),
0
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.strLen', async cluster => {
assert.equal(
await cluster.strLen('key'),
0
);
}, GLOBAL.CLUSTERS.OPEN);
testUtils.testAll('strLen', async client => {
assert.equal(
await client.strLen('key'),
0
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
export function transformArguments(index1: number, index2: number): Array<string> {
return ['SWAPDB', index1.toString(), index2.toString()];
}
// export function transformArguments(index1: number, index2: number): Array<string> {
// 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 testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './TIME';
// import { strict as assert } from 'assert';
// import testUtils, { GLOBAL } from '../test-utils';
// import { transformArguments } from './TIME';
describe('TIME', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments(),
['TIME']
);
});
// describe('TIME', () => {
// it('transformArguments', () => {
// assert.deepEqual(
// transformArguments(),
// ['TIME']
// );
// });
testUtils.testWithClient('client.time', async client => {
const reply = await client.time();
assert.ok(reply instanceof Date);
assert.ok(typeof reply.microseconds === 'number');
}, GLOBAL.SERVERS.OPEN);
});
// testUtils.testWithClient('client.time', async client => {
// const reply = await client.time();
// assert.ok(reply instanceof Date);
// assert.ok(typeof reply.microseconds === 'number');
// }, GLOBAL.SERVERS.OPEN);
// });

View File

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

View File

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

View File

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

View File

@@ -1,28 +1,31 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './UNLINK';
import UNLINK from './UNLINK';
describe('UNLINK', () => {
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
transformArguments('key'),
['UNLINK', 'key']
);
});
it('array', () => {
assert.deepEqual(
transformArguments(['1', '2']),
['UNLINK', '1', '2']
);
});
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
UNLINK.transformArguments('key'),
['UNLINK', 'key']
);
});
testUtils.testWithClient('client.unlink', async client => {
assert.equal(
await client.unlink('key'),
0
);
}, GLOBAL.SERVERS.OPEN);
it('array', () => {
assert.deepEqual(
UNLINK.transformArguments(['1', '2']),
['UNLINK', '1', '2']
);
});
});
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 testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './UNWATCH';
import UNWATCH from './UNWATCH';
describe('UNWATCH', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments(),
['UNWATCH']
);
});
it('transformArguments', () => {
assert.deepEqual(
UNWATCH.transformArguments(),
['UNWATCH']
);
});
testUtils.testWithClient('client.unwatch', async client => {
assert.equal(
await client.unwatch(),
'OK'
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('client.unwatch', async client => {
assert.equal(
await client.unwatch(),
'OK'
);
}, GLOBAL.SERVERS.OPEN);
});

View File

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

View File

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

View File

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

View File

@@ -1,20 +1,20 @@
import { strict as assert } from 'assert';
import { transformArguments } from './WATCH';
import WATCH from './WATCH';
describe('WATCH', () => {
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
transformArguments('key'),
['WATCH', 'key']
);
});
it('array', () => {
assert.deepEqual(
transformArguments(['1', '2']),
['WATCH', '1', '2']
);
});
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
WATCH.transformArguments('key'),
['WATCH', 'key']
);
});
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';
export default {
FIRST_KEY_INDEX: 1,
FIRST_KEY_INDEX: undefined,
IS_READ_ONLY: true,
transformArguments(key: RedisVariadicArgument) {
return pushVariadicArguments(['WATCH'], key);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -104,8 +104,20 @@ import SETEX from './SETEX';
import SETNX from './SETNX';
import SETRANGE from './SETRANGE';
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 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 ZCARD from './ZCARD';
import ZCOUNT from './ZCOUNT';
@@ -344,10 +356,34 @@ export default {
setRange: SETRANGE,
SMEMBERS,
sMembers: SMEMBERS,
SPUBLISH,
sPublish: SPUBLISH,
SRANDMEMBER_COUNT,
sRandMemberCount: SRANDMEMBER_COUNT,
SRANDMEMBER,
sRandMember: SRANDMEMBER,
SREM,
sRem: SREM,
SSCAN,
sScan: SSCAN,
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,
ZCARD,

View File

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