libpq
Version:
Low-level native bindings to PostgreSQL libpq
38 lines (31 loc) • 1.15 kB
JavaScript
var PQ = require('../');
var assert = require('assert');
var helper = require('./helper');
describe('low-level query integration tests', function () {
helper.setupIntegration();
describe('exec', function () {
before(function () {
this.pq.exec('SELECT * FROM test_data');
});
it('has correct tuples', function () {
assert.strictEqual(this.pq.ntuples(), 3);
});
it('has correct field count', function () {
assert.strictEqual(this.pq.nfields(), 2);
});
it('has correct rows', function () {
assert.strictEqual(this.pq.getvalue(0, 0), 'brian');
assert.strictEqual(this.pq.getvalue(1, 1), '30');
assert.strictEqual(this.pq.getvalue(2, 0), '');
assert.strictEqual(this.pq.getisnull(2, 0), false);
assert.strictEqual(this.pq.getvalue(2, 1), '');
assert.strictEqual(this.pq.getisnull(2, 1), true);
});
it('has correct identifiers', function() {
assert.notEqual(this.pq.ftable(0), 0);
assert.notEqual(this.pq.ftable(1), 0);
assert.strictEqual(this.pq.ftablecol(0), 1);
assert.strictEqual(this.pq.ftablecol(1), 2);
});
});
});