Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

catbox-redis

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

catbox-redis - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

CONTRIBUTING.md

8

lib/index.js

@@ -40,2 +40,6 @@ // Load modules

}
if (this.settings.database) {
client.select(this.settings.database);
}

@@ -50,4 +54,2 @@ // Listen to errors

}
self.stop();
});

@@ -77,3 +79,3 @@

return (!!this.client);
return !!this.client && this.client.connected;
};

@@ -80,0 +82,0 @@

{
"name": "catbox-redis",
"description": "Redis adapter for catbox",
"version": "1.0.4",
"version": "1.0.5",
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)",

@@ -20,8 +20,9 @@ "contributors": [

"dependencies": {
"redis": "0.10.x",
"redis": "0.12.x",
"hoek": "2.x.x"
},
"devDependencies": {
"catbox": "3.x.x",
"lab": "3.x.x"
"catbox": "4.x.x",
"code": "1.x.x",
"lab": "5.x.x"
},

@@ -28,0 +29,0 @@ "scripts": {

@@ -1,2 +0,2 @@

catbox-redis
catbox-redis [![Build Status](https://travis-ci.org/hapijs/catbox-redis.svg?branch=master)](https://travis-ci.org/hapijs/catbox-redis)
============

@@ -6,5 +6,5 @@

Lead Maintainer: [Eran Hammer](https://github.com/hueniverse)
Lead Maintainer: [Loic Mahieu](https://github.com/LoicMahieu)
### Options
## Options

@@ -14,2 +14,12 @@ - `host` - the Redis server hostname. Defaults to `'127.0.0.1'`.

- `password` - the Redis authentication password when required.
- `database` - the Redis database.
- `partition` - this will store items under keys that start with this value. (Default: '')
## Tests
The test suite expects a redis server to be running on port 6379.
```sh
redis-server&
npm test
```
// Load modules
var Code = require('code');
var Lab = require('lab');

@@ -15,7 +16,6 @@ var Catbox = require('catbox');

var expect = Lab.expect;
var before = Lab.before;
var after = Lab.after;
var describe = Lab.experiment;
var it = Lab.test;
var lab = exports.lab = Lab.script();
var expect = Code.expect;
var describe = lab.describe;
var it = lab.test;

@@ -66,3 +66,3 @@

expect(err).to.not.exist;
expect(err).to.not.exist();
client.get(key, function (err, result) {

@@ -119,3 +119,3 @@

expect(err).to.not.exist;
expect(err).to.not.exist();
expect(client.isReady()).to.equal(true);

@@ -125,3 +125,3 @@

expect(err).to.not.exist;
expect(err).to.not.exist();
expect(client.isReady()).to.equal(true);

@@ -155,3 +155,3 @@ done();

expect(err).to.not.exist;
expect(err).to.not.exist();
setTimeout(function () {

@@ -230,3 +230,3 @@

expect(err).to.not.exist;
expect(err).to.not.exist();
done();

@@ -257,4 +257,4 @@ });

expect(err).to.exist;
expect(result).to.not.exist;
expect(err).to.exist();
expect(result).to.not.exist();
done();

@@ -271,3 +271,3 @@ });

expect(err).to.exist;
expect(err).to.exist();
done();

@@ -284,3 +284,3 @@ });

expect(err).to.exist;
expect(err).to.exist();
done();

@@ -324,3 +324,3 @@ });

expect(err).to.exist;
expect(err).to.exist();
done();

@@ -343,4 +343,4 @@ });

expect(err).to.not.exist;
expect(redis.client).to.exist;
expect(err).to.not.exist();
expect(redis.client).to.exist();
done();

@@ -361,3 +361,3 @@ });

expect(err).to.not.exist;
expect(err).to.not.exist();
var client = redis.client;

@@ -384,5 +384,5 @@

expect(err).to.exist;
expect(err).to.exist();
expect(err).to.be.instanceOf(Error);
expect(redis.client).to.not.exist;
expect(redis.client).to.not.exist();
done();

@@ -413,4 +413,22 @@ });

});
it('sends select command when database is provided', function (done) {
var options = {
host: '127.0.0.1',
port: 6379,
database: 1
};
var redis = new Redis(options);
redis.start(function () {});
// redis.client.selected_db gets updated after the callback
setTimeout(function () {
expect(redis.client.selected_db).to.equal(1);
done();
}, 10);
});
it('stops the client on error post connection', function (done) {
it('does not stops the client on error post connection', function (done) {

@@ -426,7 +444,7 @@ var options = {

expect(err).to.not.exist;
expect(redis.client).to.exist;
expect(err).to.not.exist();
expect(redis.client).to.exist();
redis.client.emit('error', new Error('injected'));
expect(redis.client).to.not.exist;
expect(redis.client).to.exist();
done();

@@ -437,2 +455,71 @@ });

describe('#isReady', function () {
it ('returns true when when connected', function (done) {
var options = {
host: '127.0.0.1',
port: 6379
};
var redis = new Redis(options);
redis.start(function (err) {
expect(err).to.not.exist();
expect(redis.isReady()).to.equal(true);
redis.stop();
done();
});
});
it ('returns false when stopped', function (done) {
var options = {
host: '127.0.0.1',
port: 6379
};
var redis = new Redis(options);
redis.start(function (err) {
expect(err).to.not.exist();
expect(redis.isReady()).to.equal(true);
redis.stop();
expect(redis.isReady()).to.equal(false);
done();
});
});
it ('returns false when disconnected', function (done) {
var options = {
host: '127.0.0.1',
port: 6379
};
var redis = new Redis(options);
redis.start(function (err) {
expect(err).to.not.exist();
expect(redis.client).to.exist();
expect(redis.isReady()).to.equal(true);
redis.client.end();
expect(redis.isReady()).to.equal(false);
redis.stop();
done();
});
});
});
describe('#validateSegmentName', function () {

@@ -501,3 +588,3 @@

expect(err).to.exist;
expect(err).to.exist();
expect(err).to.be.instanceOf(Error);

@@ -526,3 +613,3 @@ expect(err.message).to.equal('Connection not started');

expect(err).to.exist;
expect(err).to.exist();
expect(err).to.be.instanceOf(Error);

@@ -550,3 +637,3 @@ done();

expect(err).to.exist;
expect(err).to.exist();
expect(err.message).to.equal('Bad envelope content');

@@ -574,3 +661,3 @@ done();

expect(err).to.exist;
expect(err).to.exist();
expect(err.message).to.equal('Incorrect envelope structure');

@@ -598,3 +685,3 @@ done();

expect(err).to.exist;
expect(err).to.exist();
expect(err.message).to.equal('Incorrect envelope structure');

@@ -623,6 +710,6 @@ done();

expect(err).to.not.exist;
expect(err).to.not.exist();
redis.get(key, function (err, result) {
expect(err).to.not.exist;
expect(err).to.not.exist();
expect(result.item).to.equal('myvalue');

@@ -653,4 +740,4 @@ done();

expect(err).to.not.exist;
expect(result).to.not.exist;
expect(err).to.not.exist();
expect(result).to.not.exist();
done();

@@ -675,3 +762,3 @@ });

expect(err).to.exist;
expect(err).to.exist();
expect(err).to.be.instanceOf(Error);

@@ -700,3 +787,3 @@ expect(err.message).to.equal('Connection not started');

expect(err).to.exist;
expect(err).to.exist();
expect(err).to.be.instanceOf(Error);

@@ -721,3 +808,3 @@ done();

expect(err).to.exist;
expect(err).to.exist();
expect(err).to.be.instanceOf(Error);

@@ -746,3 +833,3 @@ expect(err.message).to.equal('Connection not started');

expect(err).to.not.exist;
expect(err).to.not.exist();
done();

@@ -766,5 +853,5 @@ });

expect(redis.client).to.exist;
expect(redis.client).to.exist();
redis.stop();
expect(redis.client).to.not.exist;
expect(redis.client).to.not.exist();
done();

@@ -771,0 +858,0 @@ });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc