Skip to content

Commit

Permalink
Added integration test for overriding type parsers on a per-client ba…
Browse files Browse the repository at this point in the history
…sis.
  • Loading branch information
whitelynx committed Dec 3, 2014
1 parent e2ea482 commit 5fff5fc
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/integration/client/type-parser-override-tests.js
@@ -0,0 +1,34 @@
var helper = require(__dirname + '/test-helper');

function testTypeParser(client, expectedResult, done) {
var boolValue = true;
client.query('CREATE TEMP TABLE parserOverrideTest(id bool)');
client.query('INSERT INTO parserOverrideTest(id) VALUES ($1)', [boolValue]);
client.query('SELECT * FROM parserOverrideTest', assert.success(function(result) {
assert.equal(result.rows[0].id, expectedResult);
helper.pg.end();
done();
}));
}

helper.pg.connect(helper.config, assert.success(function(client1, done1) {
helper.pg.connect(helper.config, assert.success(function(client2, done2) {
var boolTypeOID = 16;
client1.setTypeParser(boolTypeOID, function(){
return 'first client';
});
client2.setTypeParser(boolTypeOID, function(){
return 'second client';
});

client1.setTypeParser(boolTypeOID, 'binary', function(){
return 'first client binary';
});
client2.setTypeParser(boolTypeOID, 'binary', function(){
return 'second client binary';
});

testTypeParser(client1, 'first client', done1);
testTypeParser(client2, 'second client', done2);
}));
}));

0 comments on commit 5fff5fc

Please sign in to comment.