Fix conditional loading of firebird test for travis-ci

This commit is contained in:
Timothy Warren 2014-11-04 12:52:02 -05:00
parent d554372912
commit 7ef2385da9

View File

@ -14,70 +14,71 @@ try {
var Firebird = require(adapterName); var Firebird = require(adapterName);
var conn = null; var conn = null;
var qb = null; var qb = null;
// Setup testbase from the inside out
// Because the connection is async, utilize
// the setUp function from nodeunit to get the connection
testBase.tests.setUp = function(cb) {
if ( ! conn)
{
// Connect to the database
Firebird.attach(config.conn, function(err, db) {
if (err) {
throw new Error(err);
console.error(err);
}
conn = db;
// Set up the query builder object
qb = nodeQuery.init('firebird', db, adapterName);
testBase._setUp(qb, function(test, err, result) {
if (err) {
test.done();
throw new Error(err);
}
result = result || [];
test.ok(result, 'firebird: Valid result for generated query');
test.done();
});
cb();
});
}
else
{
cb();
}
};
//delete testBase.tests['DB update tests'];
testBase.tests['DB update tests']['Test Insert Batch'] = function(test) {
test.expect(1);
test.throws(function() {
qb.insertBatch({}, (function() {}));
}, Error, "Insert Batch not implemented for firebird");
test.done();
};
testBase.tests["firebird adapter with query builder"] = function(test) {
test.expect(1);
test.ok(testBase.qb);
// Disconnect from the db
conn.detach();
test.done();
};
module.exports = testBase.tests;
} catch (e) { } catch (e) {
// Export an empty testBase.testsuite if module not loaded // Export an empty testBase.testsuite if module not loaded
console.log(e); console.log(e);
console.log("Database adapter firebird not found"); console.log("Database adapter firebird not found");
module.exports = {}; module.exports = {};
} }
// Setup testbase from the inside out
// Because the connection is async, utilize
// the setUp function from nodeunit to get the connection
testBase.tests.setUp = function(cb) {
if ( ! conn)
{
// Connect to the database
Firebird.attach(config.conn, function(err, db) {
if (err) {
throw new Error(err);
console.error(err);
}
conn = db;
// Set up the query builder object
qb = nodeQuery.init('firebird', db, adapterName);
testBase._setUp(qb, function(test, err, result) {
if (err) {
test.done();
throw new Error(err);
}
result = result || [];
test.ok(result, 'firebird: Valid result for generated query');
test.done();
});
cb();
});
}
else
{
cb();
}
};
//delete testBase.tests['DB update tests'];
testBase.tests['DB update tests']['Test Insert Batch'] = function(test) {
test.expect(1);
test.throws(function() {
qb.insertBatch({}, (function() {}));
}, Error, "Insert Batch not implemented for firebird");
test.done();
};
testBase.tests["firebird adapter with query builder"] = function(test) {
test.expect(1);
test.ok(testBase.qb);
// Disconnect from the db
conn.detach();
test.done();
};
module.exports = testBase.tests;