Skip to content

Commit e469053

Browse files
committed
Cleanup test execution & makefile cruft
1 parent cb4d137 commit e469053

File tree

5 files changed

+24
-57
lines changed

5 files changed

+24
-57
lines changed

Makefile

+3-12
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ all:
1313
npm install
1414

1515
help:
16-
@echo "make prepare-test-db [connectionString=postgres://<your connection string>]"
1716
@echo "make test-all [connectionString=postgres://<your connection string>]"
1817

1918
test: test-unit
@@ -32,11 +31,7 @@ test-unit:
3231

3332
test-connection:
3433
@echo "***Testing connection***"
35-
@node script/test-connection.js $(params)
36-
37-
test-connection-binary:
38-
@echo "***Testing binary connection***"
39-
@node script/test-connection.js $(params) binary
34+
@node script/create-test-tables.js $(params)
4035

4136
test-missing-native:
4237
@echo "***Testing optional native install***"
@@ -47,7 +42,7 @@ test-missing-native:
4742
node_modules/pg-native/index.js:
4843
@npm i pg-native
4944

50-
test-native: node_modules/pg-native/index.js
45+
test-native: node_modules/pg-native/index.js test-connection
5146
@echo "***Testing native bindings***"
5247
@find test/native -name "*-tests.js" | $(node-command)
5348
@find test/integration -name "*-tests.js" | $(node-command) native
@@ -56,17 +51,13 @@ test-integration: test-connection
5651
@echo "***Testing Pure Javascript***"
5752
@find test/integration -name "*-tests.js" | $(node-command)
5853

59-
test-binary: test-connection-binary
54+
test-binary: test-connection
6055
@echo "***Testing Pure Javascript (binary)***"
6156
@find test/integration -name "*-tests.js" | $(node-command) binary
6257

6358
test-pool:
6459
@find test/integration/connection-pool -name "*.js" | $(node-command) binary
6560

66-
prepare-test-db:
67-
@echo "***Preparing the database for tests***"
68-
@find script/create-test-tables.js | $(node-command)
69-
7061
jshint:
7162
@echo "***Starting jshint***"
7263
@./node_modules/.bin/jshint lib

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"async": "0.9.0",
3131
"jshint": "2.5.2",
3232
"lodash": "4.13.1",
33-
"pg-copy-streams": "0.3.0"
33+
"pg-copy-streams": "0.3.0",
34+
"promise-polyfill": "5.2.1"
3435
},
3536
"minNativeVersion": "1.7.0",
3637
"scripts": {

script/create-test-tables.js

+14-20
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,17 @@ var con = new pg.Client({
3838
database: args.database
3939
});
4040
con.connect();
41-
if(args.down) {
42-
console.log("Dropping table 'person'")
43-
var query = con.query("drop table if exists person");
44-
query.on('end', function() {
45-
console.log("Dropped!");
46-
con.end();
47-
});
48-
} else {
49-
console.log("Creating table 'person'");
50-
con.query("create table person(id serial, name varchar(10), age integer)").on('end', function(){
51-
console.log("Created!");
52-
console.log("Filling it with people");
53-
});;
54-
people.map(function(person) {
55-
return con.query("insert into person(name, age) values('"+person.name + "', '" + person.age + "')");
56-
}).pop().on('end', function(){
57-
console.log("Inserted 26 people");
58-
con.end();
59-
});
60-
}
41+
var query = con.query("drop table if exists person");
42+
query.on('end', function() {
43+
console.log("Dropped table 'person'")
44+
});
45+
con.query("create table person(id serial, name varchar(10), age integer)").on('end', function(){
46+
console.log("Created table person");
47+
console.log("Filling it with people");
48+
});
49+
people.map(function(person) {
50+
return con.query("insert into person(name, age) values('"+person.name + "', '" + person.age + "')");
51+
}).pop().on('end', function(){
52+
console.log("Inserted 26 people");
53+
con.end();
54+
});

script/test-connection.js

-24
This file was deleted.

test/test-helper.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
//make assert a global...
22
assert = require('assert');
33

4+
//support for [email protected]
5+
if (typeof Promise == 'undefined') {
6+
global.Promise = require('promise-polyfill')
7+
}
8+
49
var EventEmitter = require('events').EventEmitter;
510
var sys = require('util');
611
var BufferList = require(__dirname+'/buffer-list')

0 commit comments

Comments
 (0)