added test-binary target

integration tests could now be started in binary mode
some tests are executed in text mode anyway, they are currently not
compatible with binary mode or prepared statements at all
(f.e. multiple statements in one query)
This commit is contained in:
Alexander Sulfrian 2011-11-22 04:59:54 +01:00
parent 2b7c57710c
commit 6b032c466b
6 changed files with 23 additions and 8 deletions

View File

@ -14,7 +14,7 @@ node-command := xargs -n 1 -I file node file $(params)
.PHONY : test test-connection test-integration bench test-native build/default/binding.node
test: test-unit
test-all: test-unit test-integration test-native
test-all: test-unit test-integration test-native test-binary
bench:
@find benchmark -name "*-bench.js" | $(node-command)
@ -28,6 +28,9 @@ test-unit:
test-connection:
@node script/test-connection.js $(params)
test-connection-binary:
@node script/test-connection.js $(params) --binary true
test-native: build/default/binding.node
@echo "***Testing native bindings***"
@find test/native -name "*-tests.js" | $(node-command)
@ -36,3 +39,7 @@ test-native: build/default/binding.node
test-integration: test-connection
@echo "***Testing Pure Javascript***"
@find test/integration -name "*-tests.js" | $(node-command)
test-binary: test-connection-binary
@echo "***Testing Pure Javascript (binary)***"
@find test/integration -name "*-tests.js" | $(node-command) --binary true

View File

@ -5,11 +5,11 @@ test("empty query message handling", function() {
assert.emits(client, 'drain', function() {
client.end();
});
client.query("");
client.query({text: "", binary: false});
});
test('callback supported', assert.calls(function() {
client.query("", function(err, result) {
client.query({text: "", binary: false}, function(err, result) {
assert.isNull(err);
assert.empty(result.rows);
})

View File

@ -30,7 +30,7 @@ test('error handling', function(){
var client = createErorrClient();
var q = client.query("CREATE TEMP TABLE boom(age integer); INSERT INTO boom (age) VALUES (28);");
var q = client.query({text: "CREATE TEMP TABLE boom(age integer); INSERT INTO boom (age) VALUES (28);", binary: false});
test("when query is parsing", function() {

View File

@ -37,7 +37,7 @@ test("simple query interface", function() {
test("multiple simple queries", function() {
var client = helper.client();
client.query("create temp table bang(id serial, name varchar(5));insert into bang(name) VALUES('boom');")
client.query({ text: "create temp table bang(id serial, name varchar(5));insert into bang(name) VALUES('boom');", binary: false })
client.query("insert into bang(name) VALUES ('yes');");
var query = client.query("select name from bang");
assert.emits(query, 'row', function(row) {
@ -51,9 +51,9 @@ test("multiple simple queries", function() {
test("multiple select statements", function() {
var client = helper.client();
client.query("create temp table boom(age integer); insert into boom(age) values(1); insert into boom(age) values(2); insert into boom(age) values(3)");
client.query("create temp table bang(name varchar(5)); insert into bang(name) values('zoom');");
var result = client.query("select age from boom where age < 2; select name from bang");
client.query({text: "create temp table boom(age integer); insert into boom(age) values(1); insert into boom(age) values(2); insert into boom(age) values(3)", binary: false});
client.query({text: "create temp table bang(name varchar(5)); insert into bang(name) values('zoom');", binary: false});
var result = client.query({text: "select age from boom where age < 2; select name from bang", binary: false});
assert.emits(result, 'row', function(row) {
assert.strictEqual(row['age'], 1);
assert.emits(result, 'row', function(row) {

View File

@ -79,6 +79,13 @@ var types = [{
values: ['13:12:12.321', null]
}];
// ignore some tests in binary mode
if (helper.config.binary) {
types = types.filter(function(type) {
return !(type.name in {'real':1, 'timetz':1, 'time':1});
});
}
var valueCount = 0;
types.forEach(function(type) {
valueCount += type.values.length;

View File

@ -6,6 +6,7 @@ helper.pg.defaults.password = helper.args.password;
helper.pg.defaults.database = helper.args.database;
helper.pg.defaults.port = helper.args.port;
helper.pg.defaults.host = helper.args.host;
helper.pg.defaults.binary = helper.args.binary;
helper.pg.defaults.poolIdleTimeout = 100;
var moreArgs = {};