-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpg-server-tests.js
33 lines (29 loc) · 1.07 KB
/
pg-server-tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var PREFIX = 'numtel:pg-server - ';
var PORT = 5439; // Keep in sync with test.pg.json
var CONN_STR = 'postgres://'
+ process.env.USER + ':' // Default user is same as system user
+ 'numtel' // From defaultpw file in NPM package
+ '@localhost:' + PORT
+ '/postgres'; // Default database
Tinytest.addAsync(PREFIX + 'Simple Query', function (test, testDone) {
pg.connect(CONN_STR, Meteor.bindEnvironment(function(error, client, pgDone) {
if(error) throw error;
client.query('SELECT 1+1 AS result', Meteor.bindEnvironment(
function(error, result) {
test.equal(result.rows[0].result, 2);
pgDone();
testDone();
}));
}));
});
Tinytest.addAsync(PREFIX + 'Initialization Queries', function (test, testDone) {
pg.connect(CONN_STR, Meteor.bindEnvironment(function(error, client, pgDone) {
if(error) throw error;
client.query('SELECT * FROM test_table', Meteor.bindEnvironment(
function(error, result) {
test.equal(result.rows[0].col, 25);
pgDone();
testDone();
}));
}));
});