Skip to content

Commit

Permalink
fix: update package engines to match ioredis
Browse files Browse the repository at this point in the history
  • Loading branch information
vsumner committed May 24, 2023
1 parent 4175f2d commit 69f648e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"ioredis": "5.x"
},
"engines": {
"node": ">= 14"
"node": ">= 12.22.0"
},
"files": [
"lib"
Expand Down
15 changes: 8 additions & 7 deletions test/async.test.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
const should = require('should');

// allow the default url to be overriden for local testing
const redisUrl = process.env.REDIS_URL ? process.env.REDIS_URL : 'redis://localhost:6379/';

const redisUrl = process.env.REDIS_URL
? process.env.REDIS_URL
: 'redis://localhost:6379/';

if (parseFloat(process.version.slice(1)) >= 7.6) {
describe('test/async.test.js', function() {
it('should set with ttl ok', async () => {
const store = require('..')({url: redisUrl});
const store = require('..')({ url: redisUrl });
await store.set('key:ttl', { a: 1 }, 86400000);
(await store.get('key:ttl')).should.eql({ a: 1 });
(await store.client.ttl('key:ttl')).should.equal(86400);
await store.quit();
});

it('should not throw error with bad JSON', async () => {
const store = require('..')({url: redisUrl});
const store = require('..')({ url: redisUrl });
await store.client.set('key:badKey', '{I will cause an error!}');
should.not.exist(await store.get('key:badKey'));
await store.quit();
});

it('should set without ttl ok', async () => {
const store = require('..')({url: redisUrl});
const store = require('..')({ url: redisUrl });
await store.set('key:nottl', { a: 1 });
(await store.get('key:nottl')).should.eql({ a: 1 });
(await store.client.ttl('key:nottl')).should.equal(-1);
await store.quit();
});

it('should destroy ok', async () => {
const store = require('..')({url: redisUrl});
const store = require('..')({ url: redisUrl });
await store.destroy('key:nottl');
await store.destroy('key:ttl');
await store.destroy('key:badKey');
Expand All @@ -48,7 +49,7 @@ if (parseFloat(process.version.slice(1)) >= 7.6) {
});
}

const store = require('..')({url: redisUrl});
const store = require('..')({ url: redisUrl });
await store.set('key:ttl2', { a: 1, b: 2 }, 1000);
await sleep(1200); // Some odd delay introduced by co-mocha
should.not.exist(await store.get('key:ttl2'));
Expand Down
14 changes: 8 additions & 6 deletions test/koa-redis.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const should = require('should');
const Redis = require('ioredis');

// allow the default url to be overriden for local testing
const redisUrl = process.env.REDIS_URL ? process.env.REDIS_URL : 'redis://localhost:6379/';
const redisUrl = process.env.REDIS_URL
? process.env.REDIS_URL
: 'redis://localhost:6379/';

function event(object, name) {
// Convert events to promises
Expand Down Expand Up @@ -74,15 +76,15 @@ describe('test/koa-redis.test.js', () => {
});

it('should set with ttl ok', function*() {
const store = require('..')({url: redisUrl});
const store = require('..')({ url: redisUrl });
yield store.set('key:ttl', { a: 1 }, 86400000);
(yield store.get('key:ttl')).should.eql({ a: 1 });
(yield store.client.ttl('key:ttl')).should.equal(86400);
yield store.quit();
});

it('should not throw error with bad JSON', function*() {
const store = require('..')({url: redisUrl});
const store = require('..')({ url: redisUrl });
yield store.client.set('key:badKey', '{I will cause an error!}');
should.not.exist(yield store.get('key:badKey'));
yield store.quit();
Expand Down Expand Up @@ -111,15 +113,15 @@ describe('test/koa-redis.test.js', () => {
});

it('should set without ttl ok', function*() {
const store = require('..')({url: redisUrl});
const store = require('..')({ url: redisUrl });
yield store.set('key:nottl', { a: 1 });
(yield store.get('key:nottl')).should.eql({ a: 1 });
(yield store.client.ttl('key:nottl')).should.equal(-1);
yield store.quit();
});

it('should destroy ok', function*() {
const store = require('..')({url: redisUrl});
const store = require('..')({ url: redisUrl });
yield store.destroy('key:nottl');
yield store.destroy('key:ttl');
yield store.destroy('key:badKey');
Expand All @@ -137,7 +139,7 @@ describe('test/koa-redis.test.js', () => {
});
}

const store = require('..')({url: redisUrl});
const store = require('..')({ url: redisUrl });
yield store.set('key:ttl2', { a: 1, b: 2 }, 1000);
yield sleep(1200); // Some odd delay introduced by co-mocha
should.not.exist(yield store.get('key:ttl2'));
Expand Down

0 comments on commit 69f648e

Please sign in to comment.