From 9cc3e527da5fb8c2a2cfeb1880f4db77aacf7160 Mon Sep 17 00:00:00 2001 From: Stephen Sugden Date: Wed, 21 May 2014 22:42:35 +0200 Subject: [PATCH] add failing test for noData queries --- test/no-data-handling.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/no-data-handling.js diff --git a/test/no-data-handling.js b/test/no-data-handling.js new file mode 100644 index 00000000..9bcbef83 --- /dev/null +++ b/test/no-data-handling.js @@ -0,0 +1,25 @@ +var assert = require('assert') +var pg = require('pg.js'); +var Cursor = require('../'); + +describe('queries with no data', function () { + beforeEach(function(done) { + var client = this.client = new pg.Client() + client.connect(done) + }) + + + afterEach(function() { + this.client.end() + }) + + it('handles queries that return no data', function (done) { + var cursor = new Cursor('CREATE TEMPORARY TABLE whatwhat (thing int)') + this.client.query(cursor) + cursor.read(100, function (err, rows) { + assert.ifError(err) + assert.equal(rows.length, 0) + done() + }) + }); +});