node-postgres/test/integration/client/result-metadata-tests.js
Charmander 8ce7e13b93 Make tests compatible with PostgreSQL 10
PostgreSQL 10 reports its version as only `major.minor`, so it can’t be parsed with semver. The `server_version_num` setting is a major version followed by a four-digit minor version since version 10, and was a three-digit major version followed by a two-digit minor version before that.
2018-05-23 17:54:51 +02:00

37 lines
1.3 KiB
JavaScript

var helper = require(__dirname + "/test-helper");
var pg = helper.pg;
test('should return insert metadata', function() {
pg.connect(helper.config, assert.calls(function(err, client, done) {
assert.isNull(err);
helper.versionGTE(client, '90000', assert.success(function(hasRowCount) {
client.query("CREATE TEMP TABLE zugzug(name varchar(10))", assert.calls(function(err, result) {
assert.isNull(err);
assert.equal(result.oid, null);
assert.equal(result.command, 'CREATE');
var q = client.query("INSERT INTO zugzug(name) VALUES('more work?')", assert.calls(function(err, result) {
assert.isNull(err);
assert.equal(result.command, "INSERT");
assert.equal(result.rowCount, 1);
client.query('SELECT * FROM zugzug', assert.calls(function(err, result) {
assert.isNull(err);
if(hasRowCount) assert.equal(result.rowCount, 1);
assert.equal(result.command, 'SELECT');
process.nextTick(pg.end.bind(pg));
}));
}));
assert.emits(q, 'end', function(result) {
assert.equal(result.command, "INSERT");
if(hasRowCount) assert.equal(result.rowCount, 1);
done();
});
}));
}));
}));
});