Skip to content

Commit

Permalink
Merge branch 'master' into profile-add-column-sql
Browse files Browse the repository at this point in the history
  • Loading branch information
iamigo committed Aug 15, 2017
2 parents 0accab2 + 0eaab95 commit ca9b860
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 145 deletions.
19 changes: 9 additions & 10 deletions tests/clock/kueStatsActivityLogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ const TWO = 2;
const client = redis.client.realtimeLogging;

describe('kueStatsActivityLogs', () => {
it('generateLogObject', (done) => {
it('generateLogObject', () => {
k.generateLogObject()
.then((obj) => {
expect(obj).to.be.an('object');
expect(obj).to.have.property('activity', 'kueStats');
expect(obj).to.have.property('activeCount');
expect(obj).to.have.property('completeCount');
expect(obj).to.have.property('failedCount');
expect(obj).to.have.property('inactiveCount');
expect(obj).to.have.property('workTimeMillis');
done();
})
expect(obj).to.be.an('object');
expect(obj).to.have.property('activity', 'kueStats');
expect(obj).to.have.property('activeCount');
expect(obj).to.have.property('completeCount');
expect(obj).to.have.property('failedCount');
expect(obj).to.have.property('inactiveCount');
expect(obj).to.have.property('workTimeMillis');
});
});
});
118 changes: 43 additions & 75 deletions tests/config/configUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,164 +10,132 @@
* tests/config/configUtil.js
*
* Tests config utilities
*/

*/
'use strict';
const expect = require('chai').expect;
const configUtil = require('../../config/configUtil');

const NOT_ALLOWED = 'Your IP address is not allowed. Verify your ' +
'network address and your Refocus IP settings';

describe('IP List', () => {
it('parse default IP list', (done) => {
it('parse default IP list', () => {
const iplist = configUtil.parseIPlist('[[0.0.0.0,255.255.255.255]]');
expect(iplist).to.have.length(1);
expect(iplist).to.be.eql([['0.0.0.0', '255.255.255.255']]);
done();
});

it('parse IP list with space around opening bracket', (done) => {
const iplist = configUtil.parseIPlist('[ [1.2.3.4,1.2.3.8],[7.6.5.4,7.6.9.9]]');
it('parse IP list with space around opening bracket', () => {
const iplist =
configUtil.parseIPlist('[ [1.2.3.4,1.2.3.8],[7.6.5.4,7.6.9.9]]');
expect(iplist).to.have.length(2);
expect(iplist).to.be.eql([
['1.2.3.4', '1.2.3.8'],
['7.6.5.4', '7.6.9.9'],
]);
done();
});

it('parse IP list with space around closing bracket', (done) => {
const iplist = configUtil
.parseIPlist('[[1.2.3.4,1.2.3.8],[7.6.5.4,7.6.9.9 ] ]');
it('parse IP list with space around closing bracket', () => {
const iplist =
configUtil.parseIPlist('[[1.2.3.4,1.2.3.8],[7.6.5.4,7.6.9.9 ] ]');
expect(iplist).to.have.length(2);
expect(iplist).to.be.eql([
['1.2.3.4', '1.2.3.8'],
['7.6.5.4', '7.6.9.9'],
]);
done();
});

it('parse IP list with space around comma', (done) => {
const iplist = configUtil
.parseIPlist('[[1.2.3.4, 1.2.3.8], [7.6.5.4,7.6.9.9]]');
it('parse IP list with space around comma', () => {
const iplist =
configUtil.parseIPlist('[[1.2.3.4, 1.2.3.8], [7.6.5.4,7.6.9.9]]');
expect(iplist).to.have.length(2);
expect(iplist).to.be.eql([
['1.2.3.4', '1.2.3.8'],
['7.6.5.4', '7.6.9.9'],
]);
done();
});

it('parse IP list with misc spaces', (done) => {
it('parse IP list with misc spaces', () => {
const iplist = configUtil
.parseIPlist('[ [ 1.2.3.4, 1.2.3.8], [7.6.5.4, 7.6.9.9 ] ]');
expect(iplist).to.have.length(2);
expect(iplist).to.be.eql([
['1.2.3.4', '1.2.3.8'],
['7.6.5.4', '7.6.9.9'],
]);
done();
});

it('error parsing IP list with wrong format', (done) => {
it('error parsing IP list with wrong format', () => {
expect(configUtil.parseIPlist.bind(
configUtil.parseIPlist, '[ [ 1.2.3.4, 1.2.3.8], [7.6.5.4] ]')
)
.to.throw(NOT_ALLOWED);
done();
});
});

describe('csvToArray', () => {
it('undefined string', (done) => {
expect(configUtil.csvToArray(undefined))
.to.be.eql([]);
done();
it('undefined string', () => {
expect(configUtil.csvToArray(undefined)).to.be.eql([]);
});

it('null string', (done) => {
expect(configUtil.csvToArray(null))
.to.be.eql([]);
done();
it('null string', () => {
expect(configUtil.csvToArray(null)).to.be.eql([]);
});

it('zero-length string', (done) => {
expect(configUtil.csvToArray(''))
.to.be.eql([]);
done();
it('zero-length string', () => {
expect(configUtil.csvToArray('')).to.be.eql([]);
});

it('single element', (done) => {
expect(configUtil.csvToArray('abc'))
.to.be.eql(['abc']);
done();
it('single element', () => {
expect(configUtil.csvToArray('abc')).to.be.eql(['abc']);
});

it('multiple elements with extra left and right padding', (done) => {
it('multiple elements with extra left and right padding', () => {
expect(configUtil.csvToArray('abc,def , ghi'))
.to.be.eql(['abc', 'def', 'ghi']);
done();
});
}); // csvToArray

describe('csvToArray', () => {
it('undefined string', (done) => {
expect(configUtil.csvToArray(undefined))
.to.be.eql([]);
done();
it('undefined string', () => {
expect(configUtil.csvToArray(undefined)).to.be.eql([]);
});

it('null string', (done) => {
expect(configUtil.csvToArray(null))
.to.be.eql([]);
done();
it('null string', () => {
expect(configUtil.csvToArray(null)).to.be.eql([]);
});

it('zero-length string', (done) => {
expect(configUtil.csvToArray(''))
.to.be.eql([]);
done();
it('zero-length string', () => {
expect(configUtil.csvToArray('')).to.be.eql([]);
});

it('single element', (done) => {
expect(configUtil.csvToArray('abc'))
.to.be.eql(['abc']);
done();
it('single element', () => {
expect(configUtil.csvToArray('abc')).to.be.eql(['abc']);
});

it('multiple elements with extra left and right padding', (done) => {
it('multiple elements with extra left and right padding', () => {
expect(configUtil.csvToArray('abc,def , ghi'))
.to.be.eql(['abc', 'def', 'ghi']);
done();
});
}); // csvToArray

describe('getReadReplicas', () => {
it('only bad entry will return undefined', (done) => {
const pe = { 'REPLICAS': 'test' };
expect(configUtil.getReadReplicas(pe, 'REPLICAS'))
.to.be.eql(undefined);
done();
it('only bad entry will return undefined', () => {
const pe = { REPLICAS: 'test' };
expect(configUtil.getReadReplicas(pe, 'REPLICAS')).to.be.eql(undefined);
});

it('without Replicas env variable return undefined', (done) => {
it('without Replicas env variable return undefined', () => {
const pe = {};
expect(configUtil.getReadReplicas(pe, 'REPLICAS'))
.to.be.eql(undefined);
done();
expect(configUtil.getReadReplicas(pe, 'REPLICAS')).to.be.eql(undefined);
});

it('Replicas env variable with correct env variables', (done) => {
const pe = { 'REPLICAS': 'test', 'test': 'testURL' };
expect(configUtil.getReadReplicas(pe, 'REPLICAS'))
.to.be.eql(['testURL']);
done();
it('Replicas env variable with correct env variables', () => {
const pe = { REPLICAS: 'test', test: 'testURL' };
expect(configUtil.getReadReplicas(pe, 'REPLICAS')).to.be.eql(['testURL']);
});

it('Replicas env variable with bad env variables', (done) => {
const pe = { 'REPLICAS': 'test, test1', 'test': 'testURL' };
expect(configUtil.getReadReplicas(pe, 'REPLICAS'))
.to.be.eql(['testURL']);
done();
it('Replicas env variable with bad env variables', () => {
const pe = { REPLICAS: 'test, test1', test: 'testURL' };
expect(configUtil.getReadReplicas(pe, 'REPLICAS')).to.be.eql(['testURL']);
});
});
16 changes: 4 additions & 12 deletions tests/jobQueue/v1/bulkUpsert.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* tests/jobQueue/v1/bulkUpsert.js
*/
'use strict'; // eslint-disable-line strict

const jobQueue = require('../../../jobQueue/setup').jobQueue;
const jobType = require('../../../jobQueue/setup').jobType;
const bulkUpsertSamplesJob = require('../../../worker/jobs/bulkUpsertSamplesJob');
Expand Down Expand Up @@ -84,16 +83,10 @@ describe('api: POST using worker process ' + path, () => {
.expect(constants.httpStatus.OK)
.expect((res) => {
expect(res.body.status).to.contain('OK');
// make sure that the jobId is returned as a part of the response.
/* make sure that the jobId is returned as a part of the response. */
expect(res.body.jobId).to.be.at.least(1);
})
.end((err) => {
if (err) {
done(err);
}

done();
});
.end(done);
});

it('test logging', (done) => {
Expand All @@ -119,7 +112,7 @@ describe('api: POST using worker process ' + path, () => {
.expect(constants.httpStatus.OK)
.end((err, res) => {
if (err) {
done(err);
return done(err);
}

//don't call done() yet, need to wait for data to be logged
Expand Down Expand Up @@ -189,7 +182,6 @@ describe('api: POST using worker process ' + path, () => {
done(err);
}
}

};
});

Expand All @@ -215,7 +207,7 @@ describe('api: POST using worker process ' + path, () => {
},
])
.expect(constants.httpStatus.BAD_REQUEST)
.end((err) => err ? done(err) : done());
.end(done);
});
});
});
Expand Down

0 comments on commit ca9b860

Please sign in to comment.