apigeek-affirm
Version:
Executable English for Software Testing and more
55 lines (43 loc) • 1.52 kB
JavaScript
#!/usr/bin/env node
/**
* ApiGeek: Affirm
*
* Cron - scheduled tests
*
* (c) Lee Curtis 2016 (c) Troven 2009-2015. Apache Licensed.
*
*/
var _ = require("underscore");
var debug = require("debug")("apigeek:scheduler");
var assert = require('assert');
var CronJob = require('cron').CronJob;
module.exports = self = function(apigeek) {
if (!apigeek.config.cron) {
console.log("Missing cron: {} option in config file");
return;
}
_.each(apigeek.config.cron, function(pattern, feature) {
var options = _.extend({ noExit: true }, apigeek.config);
options.featuresPath = options.featuresPath+"/"+feature+".feature";
debug("Execution pattern: %s -> %s", pattern, options.featuresPath);
new CronJob(pattern, function() {
apigeek.execute(options, function() {
debug("Cron Completed: %s -> %s", pattern, options.featuresPath);
});
}, function() {
debug("All Completed");
// complete
if (apigeek.config.archive) {
// save results, config and parsed features to file
apigeek.archive(self.config.archive, results, feature);
}
}, true, 'GMT');
});
process.stdin.resume();
this.onComplete = function(results) {
if (self.config.archive) {
// save results, config and parsed features to file
self.archive(self.config.archive, results, feature);
}
}
}