Skip to content

Commit

Permalink
Adjust redisMock
Browse files Browse the repository at this point in the history
  • Loading branch information
dyedwiper committed Nov 26, 2024
1 parent 44d6f33 commit e2c3754
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions test/utils/redis/redisMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ const valueDict = {};
const ttlDict = {};

const RedisClientMock = class {
get(key, ...args) {
get(key) {
const value = valueDict[key];
const callback = args[args.length - 1];
callback(null, value);
return Promise.resolve(value);
}

set(key, value, ...args) {
Expand All @@ -14,21 +13,18 @@ const RedisClientMock = class {
if (ex >= 0) {
ttlDict[key] = args[ex + 1];
}
const callback = args[args.length - 1];
callback(null, true);
return Promise.resolve(true);
}

del(key, ...args) {
del(key) {
delete valueDict[key];
delete ttlDict[key];
const callback = args[args.length - 1];
callback(null, true);
return Promise.resolve(true);
}

ttl(key, ...args) {
ttl(key) {
const ttl = ttlDict[key];
const callback = args[args.length - 1];
callback(null, ttl);
return Promise.resolve(ttl);
}
};

Expand Down

0 comments on commit e2c3754

Please sign in to comment.