Skip to content

Commit 6b032c4

Browse files
committed
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)
1 parent 2b7c577 commit 6b032c4

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ node-command := xargs -n 1 -I file node file $(params)
1414
.PHONY : test test-connection test-integration bench test-native build/default/binding.node
1515
test: test-unit
1616

17-
test-all: test-unit test-integration test-native
17+
test-all: test-unit test-integration test-native test-binary
1818

1919
bench:
2020
@find benchmark -name "*-bench.js" | $(node-command)
@@ -28,6 +28,9 @@ test-unit:
2828
test-connection:
2929
@node script/test-connection.js $(params)
3030

31+
test-connection-binary:
32+
@node script/test-connection.js $(params) --binary true
33+
3134
test-native: build/default/binding.node
3235
@echo "***Testing native bindings***"
3336
@find test/native -name "*-tests.js" | $(node-command)
@@ -36,3 +39,7 @@ test-native: build/default/binding.node
3639
test-integration: test-connection
3740
@echo "***Testing Pure Javascript***"
3841
@find test/integration -name "*-tests.js" | $(node-command)
42+
43+
test-binary: test-connection-binary
44+
@echo "***Testing Pure Javascript (binary)***"
45+
@find test/integration -name "*-tests.js" | $(node-command) --binary true

test/integration/client/empty-query-tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ test("empty query message handling", function() {
55
assert.emits(client, 'drain', function() {
66
client.end();
77
});
8-
client.query("");
8+
client.query({text: "", binary: false});
99
});
1010

1111
test('callback supported', assert.calls(function() {
12-
client.query("", function(err, result) {
12+
client.query({text: "", binary: false}, function(err, result) {
1313
assert.isNull(err);
1414
assert.empty(result.rows);
1515
})

test/integration/client/error-handling-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ test('error handling', function(){
3030

3131
var client = createErorrClient();
3232

33-
var q = client.query("CREATE TEMP TABLE boom(age integer); INSERT INTO boom (age) VALUES (28);");
33+
var q = client.query({text: "CREATE TEMP TABLE boom(age integer); INSERT INTO boom (age) VALUES (28);", binary: false});
3434

3535
test("when query is parsing", function() {
3636

test/integration/client/simple-query-tests.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test("simple query interface", function() {
3737

3838
test("multiple simple queries", function() {
3939
var client = helper.client();
40-
client.query("create temp table bang(id serial, name varchar(5));insert into bang(name) VALUES('boom');")
40+
client.query({ text: "create temp table bang(id serial, name varchar(5));insert into bang(name) VALUES('boom');", binary: false })
4141
client.query("insert into bang(name) VALUES ('yes');");
4242
var query = client.query("select name from bang");
4343
assert.emits(query, 'row', function(row) {
@@ -51,9 +51,9 @@ test("multiple simple queries", function() {
5151

5252
test("multiple select statements", function() {
5353
var client = helper.client();
54-
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)");
55-
client.query("create temp table bang(name varchar(5)); insert into bang(name) values('zoom');");
56-
var result = client.query("select age from boom where age < 2; select name from bang");
54+
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});
55+
client.query({text: "create temp table bang(name varchar(5)); insert into bang(name) values('zoom');", binary: false});
56+
var result = client.query({text: "select age from boom where age < 2; select name from bang", binary: false});
5757
assert.emits(result, 'row', function(row) {
5858
assert.strictEqual(row['age'], 1);
5959
assert.emits(result, 'row', function(row) {

test/integration/client/type-coercion-tests.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ var types = [{
7979
values: ['13:12:12.321', null]
8080
}];
8181

82+
// ignore some tests in binary mode
83+
if (helper.config.binary) {
84+
types = types.filter(function(type) {
85+
return !(type.name in {'real':1, 'timetz':1, 'time':1});
86+
});
87+
}
88+
8289
var valueCount = 0;
8390
types.forEach(function(type) {
8491
valueCount += type.values.length;

test/integration/connection-pool/unique-name-tests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ helper.pg.defaults.password = helper.args.password;
66
helper.pg.defaults.database = helper.args.database;
77
helper.pg.defaults.port = helper.args.port;
88
helper.pg.defaults.host = helper.args.host;
9+
helper.pg.defaults.binary = helper.args.binary;
910
helper.pg.defaults.poolIdleTimeout = 100;
1011

1112
var moreArgs = {};

0 commit comments

Comments
 (0)