Adaptive loading of dblite test based on whether the module exists

This commit is contained in:
Timothy Warren 2014-10-31 13:15:31 -04:00
parent 5f1ec50e0b
commit df9dfcdebc

View File

@ -7,11 +7,22 @@ var tests = testBase.tests;
// Load the test config file // Load the test config file
var adapterName = 'dblite'; var adapterName = 'dblite';
var sqlite = null;
var connection = null;
// Set up the connection // Set up the connection
var sqlite = require(adapterName).withSQLite('3.8.6+'); try {
var connection = sqlite(':memory:'); sqlite = require(adapterName).withSQLite('3.8.6+');
connection = sqlite(':memory:');
} catch (e) {
// Export an empty testsuite if module not loaded
console.log(e);
console.log("Database adapter dblite not found");
return {};
}
if (connection)
{
// Set up the query builder object // Set up the query builder object
var nodeQuery = require('../../lib/node-query'); var nodeQuery = require('../../lib/node-query');
var qb = nodeQuery('sqlite', connection, adapterName); var qb = nodeQuery('sqlite', connection, adapterName);
@ -48,3 +59,11 @@ tests["dblite adapter with query builder"] = function(test) {
// Export the final test object // Export the final test object
module.exports = tests; module.exports = tests;
}
else
{
module.exports = {};
}