node-postgres/test/integration/simple-query-tests.js
2010-10-10 18:25:47 -05:00

52 lines
1.2 KiB
JavaScript

require(__dirname+"/test-helper");
//little helper to make a
//fresh client to the test DB
var makeClient = function() {
var client = new Client({
user: 'brian',
database: 'pgjstest'
});
client.on('Error', function(msg) {
console.log(msg);
});
return client;
};
var client1 = makeClient();
client1.connect();
client1.on('ReadyForQuery', function() {
console.log('client1 ready for query');
client1.disconnect();
});
var client2 = makeClient();
client2.connect();
client2.on('ReadyForQuery', function() {
console.log('client2 ready for query');
client2.disconnect();
});
var client3 = makeClient();
client3.connect();
client3.on('ReadyForQuery', function() {
console.log('client3 ready for query');
});
client3.query('create temporary table bang (id integer)');
client3.query('insert into bang(id) VALUES(1)');
var query = client3.query('select * from bang');
query.on('row', function(data) {
console.log(data);
});
query.on('end', function() {
client3.disconnect();
});
// client.query('create temporary table bang (id integer)');
// client.query('insert into bang(id) VALUES(1)');
// client.query('select * from bang',function(err, results, fields) {
// assert.equal(err, null);
// });