From 7ef2385da9b226ffb76b855235f057416377ac9e Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Tue, 4 Nov 2014 12:52:02 -0500 Subject: [PATCH] Fix conditional loading of firebird test for travis-ci --- tests/adapters/node-firebird_test.js | 125 ++++++++++++++------------- 1 file changed, 63 insertions(+), 62 deletions(-) diff --git a/tests/adapters/node-firebird_test.js b/tests/adapters/node-firebird_test.js index 19c8644..6eb6cee 100644 --- a/tests/adapters/node-firebird_test.js +++ b/tests/adapters/node-firebird_test.js @@ -14,70 +14,71 @@ try { var Firebird = require(adapterName); var conn = 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) { // Export an empty testBase.testsuite if module not loaded console.log(e); console.log("Database adapter firebird not found"); 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; \ No newline at end of file +} \ No newline at end of file