From 7a801abade51f8cb65f937064beed4323b9a144f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sat, 16 May 2020 22:49:34 -0400 Subject: [PATCH] fix: tests on redis --- src/database/redis/hash.js | 3 +++ test/database/hash.js | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/database/redis/hash.js b/src/database/redis/hash.js index 6dc2444283..afa2b7e016 100644 --- a/src/database/redis/hash.js +++ b/src/database/redis/hash.js @@ -154,6 +154,9 @@ module.exports = function (module) { }; module.deleteObjectFields = async function (key, fields) { + if (!Array.isArray(fields) || !fields.length) { + return; + } await module.client.async.hdel(key, fields); cache.delObjectCache(key); }; diff --git a/test/database/hash.js b/test/database/hash.js index 5c33ef91a3..b6aba5852f 100644 --- a/test/database/hash.js +++ b/test/database/hash.js @@ -410,6 +410,10 @@ describe('Hash methods', function () { }); }); + it('should not error if fields is empty array', async () => { + await db.deleteObjectFields('someKey', []); + }); + it('should not error if key is undefined', function (done) { db.deleteObjectField(undefined, 'someField', function (err) { assert.ifError(err);