Skip to content

Commit 9517efd

Browse files
committed
add a couple of simple integration tests for the multiResult option
1 parent 46cb93c commit 9517efd

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/integration/client/api-tests.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,26 @@ test('null and undefined are both inserted as NULL', function() {
165165
}))
166166
}))
167167
})
168+
169+
test('can configure multiResult option', function() {
170+
pg.connect(helper.config, assert.calls(function(err, client, done) {
171+
assert.isNull(err);
172+
test('result is not an array by default', function() {
173+
client.query({ text: 'select \'hi\' as val; select \'bye\' as val;' }, assert.calls(function(err, result) {
174+
assert.isNull(err);
175+
assert.equal(result instanceof Array, false);
176+
done();
177+
}))
178+
})
179+
test('result is an array when asked', function() {
180+
client.query({ text: 'select \'hi\' as val; select \'bye\' as val;', multiResult: true }, assert.calls(function(err, results) {
181+
assert.isNull(err);
182+
assert.equal(results instanceof Array, true);
183+
assert.equal(results.length, 2);
184+
assert.equal(results[0].rows[0].val, 'hi');
185+
assert.equal(results[1].rows[0].val, 'bye');
186+
done();
187+
}))
188+
})
189+
}))
190+
})

0 commit comments

Comments
 (0)