2014-11-04 12:34:05 -05:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// Load the test base
|
|
|
|
var testBase = require('../query-builder-base');
|
|
|
|
|
|
|
|
// Load the test config file
|
|
|
|
var adapterName = 'node-firebird';
|
|
|
|
var config = require('../config.json')[adapterName];
|
|
|
|
config.conn.database = __dirname + config.conn.database;
|
|
|
|
var nodeQuery = require('../../lib/node-query');
|
|
|
|
|
2014-11-04 13:07:43 -05:00
|
|
|
// Skip on TravisCi
|
|
|
|
if (process.env.CI)
|
|
|
|
{
|
|
|
|
module.exports = {};
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-11-04 12:34:05 -05:00
|
|
|
// Set up the connection
|
|
|
|
try {
|
|
|
|
var Firebird = require(adapterName);
|
|
|
|
var conn = null;
|
|
|
|
var qb = null;
|
2014-11-04 12:52:02 -05:00
|
|
|
|
|
|
|
// 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) {
|
2014-11-04 12:34:05 -05:00
|
|
|
if (err) {
|
2014-11-04 12:52:02 -05:00
|
|
|
console.error(err);
|
2014-11-04 12:34:05 -05:00
|
|
|
}
|
2014-11-04 12:52:02 -05:00
|
|
|
conn = db;
|
2014-11-04 12:34:05 -05:00
|
|
|
|
2014-11-04 12:52:02 -05:00
|
|
|
// Set up the query builder object
|
|
|
|
qb = nodeQuery.init('firebird', db, adapterName);
|
2014-11-04 12:34:05 -05:00
|
|
|
|
2014-11-04 12:52:02 -05:00
|
|
|
testBase._setUp(qb, function(test, err, result) {
|
|
|
|
if (err) {
|
|
|
|
test.done();
|
|
|
|
throw new Error(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
result = result || [];
|
2014-11-04 12:34:05 -05:00
|
|
|
|
2014-11-04 12:52:02 -05:00
|
|
|
test.ok(result, 'firebird: Valid result for generated query');
|
|
|
|
test.done();
|
|
|
|
});
|
|
|
|
|
|
|
|
cb();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-11-04 12:34:05 -05:00
|
|
|
cb();
|
2014-11-04 12:52:02 -05:00
|
|
|
}
|
|
|
|
};
|
2014-11-04 12:34:05 -05:00
|
|
|
|
2014-11-04 12:52:02 -05:00
|
|
|
//delete testBase.tests['DB update tests'];
|
|
|
|
testBase.tests['DB update tests']['Test Insert Batch'] = function(test) {
|
|
|
|
test.expect(1);
|
2014-11-04 12:34:05 -05:00
|
|
|
|
2014-11-04 12:52:02 -05:00
|
|
|
test.throws(function() {
|
|
|
|
qb.insertBatch({}, (function() {}));
|
|
|
|
}, Error, "Insert Batch not implemented for firebird");
|
2014-11-04 12:34:05 -05:00
|
|
|
|
2014-11-04 12:52:02 -05:00
|
|
|
test.done();
|
|
|
|
};
|
2014-11-04 12:34:05 -05:00
|
|
|
|
2014-11-05 17:08:56 -05:00
|
|
|
testBase.tests['nodeQuery.getQuery = nodeQuery.init'] = function(test) {
|
|
|
|
test.expect(1);
|
|
|
|
test.deepEqual(qb, nodeQuery.getQuery(), "getQuery returns same object");
|
|
|
|
test.done();
|
|
|
|
};
|
|
|
|
|
2014-11-04 12:52:02 -05:00
|
|
|
testBase.tests["firebird adapter with query builder"] = function(test) {
|
|
|
|
test.expect(1);
|
|
|
|
test.ok(testBase.qb);
|
2014-11-04 12:34:05 -05:00
|
|
|
|
2014-11-04 12:52:02 -05:00
|
|
|
// Disconnect from the db
|
|
|
|
conn.detach();
|
2014-11-04 12:34:05 -05:00
|
|
|
|
2014-11-04 12:52:02 -05:00
|
|
|
test.done();
|
|
|
|
};
|
2014-11-04 12:34:05 -05:00
|
|
|
|
2014-11-04 12:52:02 -05:00
|
|
|
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 = {};
|
|
|
|
}
|