fix(core): Handle empty keys in cache service (no-changelog) (#6854)
* fix handle empty keys in cache service * add test * add cache mock test * add simpler mocking, and add tests for all the updated methods * don't use RedisStore specifically in the mock --------- Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
committed by
GitHub
parent
5ab30fdd95
commit
fdfc6c5a92
@@ -339,4 +339,33 @@ describe('cacheService', () => {
|
||||
await expect(cacheService.get('undefValue')).resolves.toBeUndefined();
|
||||
await expect(cacheService.get('nullValue')).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
test('should handle setting empty keys', async () => {
|
||||
await cacheService.set('', null);
|
||||
await expect(cacheService.get('')).resolves.toBeUndefined();
|
||||
await cacheService.setMany([
|
||||
['', 'something'],
|
||||
['', 'something'],
|
||||
]);
|
||||
await expect(cacheService.getMany([''])).resolves.toStrictEqual([undefined]);
|
||||
await cacheService.setMany([]);
|
||||
await expect(cacheService.getMany([])).resolves.toStrictEqual([]);
|
||||
});
|
||||
|
||||
test('should handle setting empty keys (redis)', async () => {
|
||||
config.set('cache.backend', 'redis');
|
||||
config.set('executions.mode', 'queue');
|
||||
await cacheService.destroy();
|
||||
await cacheService.init();
|
||||
|
||||
await cacheService.set('', null);
|
||||
await expect(cacheService.get('')).resolves.toBeUndefined();
|
||||
await cacheService.setMany([
|
||||
['', 'something'],
|
||||
['', 'something'],
|
||||
]);
|
||||
await expect(cacheService.getMany([''])).resolves.toStrictEqual([undefined]);
|
||||
await cacheService.setMany([]);
|
||||
await expect(cacheService.getMany([])).resolves.toStrictEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user