chain-smoker
Advanced tools
Comparing version 0.2.4 to 0.2.5
@@ -1,2 +0,1 @@ | ||
var Job = require('./models/job'); | ||
var request = require('request'); | ||
@@ -40,4 +39,2 @@ var shortId = require('shortid'); | ||
console.log(params); | ||
request(params, this.handleInitialResponse.bind(this)); | ||
@@ -50,3 +47,3 @@ }; | ||
var body; | ||
if (_.isObject(body)) { | ||
if (_.isObject(this.step.body)) { | ||
body = JSON.stringify(this.step.body); | ||
@@ -64,6 +61,9 @@ } else { | ||
Step.prototype.handleInitialResponse = function(err, res, body) { | ||
// Request will return an error if actual HTTP communication fails, so we'll call that a failure. | ||
// If it does error out, there won't be a `res` object, so account for that. | ||
res = res || { statusCode: 0 }; | ||
this.err = err; | ||
this.res = res; | ||
var validations = this.validate(); | ||
validations = this.validate(err); | ||
@@ -84,3 +84,3 @@ if (validations === true || validations === false) { | ||
this.saveBody(res); | ||
this._saveBody(err, res); | ||
this.job.p('response_code', res.statusCode); | ||
@@ -92,3 +92,5 @@ this.job.saveAndUpdate(function(err) { | ||
Step.prototype.saveBody = function(res) { | ||
Step.prototype._saveBody = function(err, res) { | ||
if (err) return this.job.p('response_body', err); | ||
var body; | ||
@@ -129,3 +131,5 @@ | ||
Step.prototype.validate = function() { | ||
Step.prototype.validate = function(preFail) { | ||
if(preFail) return false; | ||
var assertions, completed; | ||
@@ -155,2 +159,4 @@ | ||
console.log(msg); | ||
var assertion = assertions[assertionKey]; | ||
@@ -157,0 +163,0 @@ if (_.isFunction(assertion)) { |
{ | ||
"name": "chain-smoker", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "Smokes a suite of tests a day (at least)", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"start": "node index.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "mocha" | ||
}, | ||
@@ -28,4 +28,7 @@ "author": "Matthew McClure <mmcclure@brightcove.com>", | ||
"chai": "^1.10.0", | ||
"mocha": "^2.1.0" | ||
"mocha": "^2.1.0", | ||
"nock": "^0.54.0", | ||
"rewire": "^2.1.3", | ||
"sinon": "^1.12.2" | ||
} | ||
} |
var expect = require('chai').expect; | ||
var helper = require('./test-helper'); | ||
var nock = require('nock'); | ||
var Step = require('../lib/step'); | ||
var sinon = require('sinon'); | ||
describe('Step', function(){ | ||
describe('Step', function() { | ||
describe('#init()', function(){ | ||
it('should save without error', function(done){ | ||
var user = new User('Luna'); | ||
user.save(function(err){ | ||
if (err) throw err; | ||
done(); | ||
}); | ||
describe('#init()', function() { | ||
var job, jobProperty, jobSave, stepReturn; | ||
beforeEach(function() { | ||
jobProperty = sinon.spy(); | ||
jobSave = sinon.spy(); | ||
job = { | ||
p: jobProperty, | ||
save: jobSave | ||
}; | ||
}); | ||
it('sets the mandatory initial job properties', function() { | ||
var step = Step(helper.step, false); | ||
step.init(job, 0); | ||
expect(jobProperty.called).to.be.true(); | ||
expect(jobProperty.calledWith('step_num', 0)).to.be.true(); | ||
expect(jobProperty.calledWith('address', helper.step.address)).to.be.true(); | ||
expect(jobProperty.calledWith('method', helper.step.method)).to.be.true(); | ||
expect(jobProperty.calledWith('callback_time_limit', helper.step.callback_time_limit)).to.be.false(); | ||
expect(jobProperty.calledWith('external_id', undefined)).to.be.false(); | ||
}); | ||
it('sets the optional fields when included', function() { | ||
helper.step.callback_time_limit = 1000; | ||
helper.step.preset_id = true; | ||
helper.step.set_external_id = '123'; | ||
var step = Step(helper.step, false); | ||
step.init(job, 0); | ||
expect(jobProperty.calledWith('callback_time_limit', helper.step.callback_time_limit)).to.be.true(); | ||
expect(jobProperty.calledWith('external_id', helper.step.set_external_id)).to.be.true(); | ||
}); | ||
it('saves the job', function() { | ||
var step = Step(helper.step, false); | ||
step.init(job, 0); | ||
expect(jobSave.called).to.be.true(); | ||
}); | ||
}); | ||
describe('#makeRequest()', function() { | ||
var scope; | ||
before(function() { | ||
scope = nock('http://example.com') | ||
.get('/') | ||
.reply(200, 'Example.com', { | ||
'Content-Type': 'text/html' | ||
}); | ||
}); | ||
it('makes an HTTP request with the specified params'); | ||
it('replaces variables in the request body'); | ||
it('calls a callback bound to the context of step'); | ||
}); | ||
describe('#handleInitialResponse()', function() { | ||
it('calls the validations on the response'); | ||
it('updates the job with the validation results'); | ||
it('updates the job with pieces of the response'); | ||
it('saves the job'); | ||
}); | ||
describe('#handleCallbackRequest()', function() { | ||
it('calls the validations on the request'); | ||
it('updates the job with the validation results'); | ||
it('saves the job'); | ||
}); | ||
describe('#validate()', function() {}); | ||
describe('#runAssertion()', function() {}); | ||
describe('#checkComplete()', function() {}); | ||
describe('#checkSuccess()', function() {}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
23832
636
2
5