yeahoffline / redis-mock

Node.js redis client mock
213 stars 111 forks source link

Sadd method does not work when adding a single member to a set #185

Open EvanPlettGML opened 3 years ago

EvanPlettGML commented 3 years ago

This line: https://github.com/yeahoffline/redis-mock/blob/84fed02fbbc76d4b3f6d1fcdda6516aa9ae2732b/lib/server/set.js#L11

prevents sad from being called with a single member. Example code:

mockRedis = require("redis-mock").createClient();
mockRedis.sadd("setName", "member");

Since only two arguments are passed, the check on line 11 resolves to true, so the method immediately exits without adding the member to the set.

EvanPlettGML commented 3 years ago

Suggestion: change line 11 to if (arguments.length < 2) {