1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00
This commit is contained in:
dovi
2023-05-01 19:06:21 -04:00
parent 4304f4dba3
commit 74caece450
5 changed files with 238 additions and 155 deletions

View File

@@ -1,118 +1,93 @@
// 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 XADD 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(
XADD.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(
XADD.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 TRIM', () => {
assert.deepEqual(
XADD.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(
XADD.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(
XADD.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(
XADD.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']
// );
// });
// });
// testUtils.testWithClient('client.xAdd', async client => {
// assert.equal(
// typeof await client.xAdd('key', '*', {
// field: 'value'
// }),
// 'string'
// );
// }, GLOBAL.SERVERS.OPEN);
// });
testUtils.testAll('xAdd', async client => {
assert.equal(
typeof await client.xAdd('key', '*', {
field: 'value'
}),
'string'
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});