Better configuration for TDR test mode

This commit is contained in:
Andrew Stewart 2014-11-06 09:48:21 -08:00
parent 277d4a51ee
commit 4c539ab9d1
4 changed files with 14 additions and 6 deletions

View File

@ -9,5 +9,8 @@
'use strict'; 'use strict';
module.exports = { module.exports = {
logging: {} logging: {},
// are we in TDR test mode? Used to stub out adaptors/drivers.
testMode: false
}; };

View File

@ -11,10 +11,13 @@
var EventEmitter = require('events').EventEmitter; var EventEmitter = require('events').EventEmitter;
var Registry = require('./registry'), var Registry = require('./registry'),
Config = require('./config'),
Logger = require('./logger'), Logger = require('./logger'),
Utils = require('./utils'); Utils = require('./utils');
var testMode = process.env.NODE_ENV === 'test' && !CYLON_TEST; var testMode = function() {
return process.env.NODE_ENV === 'test' && Config.testMode;
};
// Public: Creates a new Connection // Public: Creates a new Connection
// //
@ -107,7 +110,7 @@ Connection.prototype.initAdaptor = function(opts) {
var adaptor = module.adaptor(opts); var adaptor = module.adaptor(opts);
if (testMode) { if (testMode()) {
var testAdaptor = Registry.findByAdaptor('test').adaptor(opts); var testAdaptor = Registry.findByAdaptor('test').adaptor(opts);
for (var prop in adaptor) { for (var prop in adaptor) {

View File

@ -11,10 +11,13 @@
var EventEmitter = require('events').EventEmitter; var EventEmitter = require('events').EventEmitter;
var Registry = require('./registry'), var Registry = require('./registry'),
Config = require('./config'),
Logger = require('./logger'), Logger = require('./logger'),
Utils = require('./utils'); Utils = require('./utils');
var testMode = process.env.NODE_ENV === 'test' && !CYLON_TEST; var testMode = function() {
return process.env.NODE_ENV === 'test' && Config.testMode;
};
// Public: Creates a new Device // Public: Creates a new Device
// //
@ -120,7 +123,7 @@ Device.prototype.initDriver = function(opts) {
var driver = module.driver(opts); var driver = module.driver(opts);
if (testMode) { if (testMode()) {
var testDriver = Registry.findByDriver('test').driver(opts); var testDriver = Registry.findByDriver('test').driver(opts);
for (var prop in driver) { for (var prop in driver) {

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
process.env.NODE_ENV = 'test'; process.env.NODE_ENV = 'test';
global.CYLON_TEST = true;
var path = require('path'); var path = require('path');