From fcd1fd563bbb2ecefbdcb0571248d40ba7aedd84 Mon Sep 17 00:00:00 2001 From: Brian Carlson Date: Tue, 18 Jan 2011 22:37:37 -0600 Subject: [PATCH] add failing tests for missing query result metadata --- test/unit/client/result-metadata-tests.js | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/unit/client/result-metadata-tests.js diff --git a/test/unit/client/result-metadata-tests.js b/test/unit/client/result-metadata-tests.js new file mode 100644 index 0000000..8399ce2 --- /dev/null +++ b/test/unit/client/result-metadata-tests.js @@ -0,0 +1,37 @@ +var helper = require(__dirname + "/test-helper") + +var testForTag = function(tagText, callback) { + test('includes command tag data for tag ' + tagText, function() { + + var client = helper.client(); + client.connection.emit('readyForQuery') + + var query = client.query("whatever"); + assert.length(client.connection.queries, 1) + + assert.emits(query, 'end', function(result) { + assert.ok(result != null, "should pass something to this event") + callback(result) + }) + + client.connection.emit('commandComplete', { + text: tagText + }); + + client.connection.emit('readyForQuery'); + }) +} + +var check = function(oid, rowCount, commandType) { + return function(result) { + assert.equal(result.oid, oid); + assert.equal(result.rowCount, rowCount); + assert.equal(result.commandType, commandType); + } +} + +testForTag("INSERT 0 3", check(0, 3, "INSERT")); +testForTag("INSERT 841 1", check(841, 1, "INSERT")); +testForTag("DELETE 10", check(null, 10, "DELETE")); +testForTag("UPDATE 11", check(null, 11, "UPDATE")); +testForTag("SELECT 20", check(null, 20, "SELECT"));