Skip to content

Commit

Permalink
Merge pull request yeahoffline#153 from kamiljano/bugfix_152
Browse files Browse the repository at this point in the history
fixing the bug report - yeahoffline#152
  • Loading branch information
kamiljano authored Dec 8, 2020
2 parents d45588b + 899957b commit 149a641
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
6 changes: 5 additions & 1 deletion lib/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ exports.hget = function (mockInstance, hash, key, callback) {

if (mockInstance.storage[hash]) {
if (mockInstance.storage[hash].type === "hash") {
value = mockInstance.storage[hash].value[key];
if (mockInstance.storage[hash].value.hasOwnProperty(key)) {
value = mockInstance.storage[hash].value[key];
} else {
value = null;
}
} else {
err = new Error("ERR Operation against a key holding the wrong kind of value");
}
Expand Down
20 changes: 2 additions & 18 deletions test/redis-mock.hash.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,6 @@ describe("basic hashing usage", function () {

});

it("should toString on non-string values", function (done) {
var testArray = [1,2,3];

r.hset(testHash, testKey, testArray, function (err, result) {

r.hget(testHash, testKey, function (err, result) {

result.should.equal(testArray.toString());

done();

});

});

});

it("should treat empty string as existent", function (done) {
r.hset(testHash, testKeyEmptyString, testValueEmptyString, function (err, result) {
r.hexists(testHash, testKeyEmptyString, function (err, result) {
Expand Down Expand Up @@ -122,7 +105,8 @@ describe("basic hashing usage", function () {

r.hget(testHash, testKeyNotExist, function (err, result) {

should.not.exist(result);
should(result).be.null();
should(err).be.null();

done();

Expand Down

0 comments on commit 149a641

Please sign in to comment.