Skip to content

Commit 975e9c5

Browse files
lukemurraydwelle
authored andcommitted
add a couple of simple integration tests for the multiResult option
1 parent 804f49d commit 975e9c5

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/integration/client/api-tests.js

+23
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,26 @@ test('null and undefined are both inserted as NULL', function() {
171171
}))
172172
}))
173173
})
174+
175+
test('can configure multiResult option', function() {
176+
pg.connect(helper.config, assert.calls(function(err, client, done) {
177+
assert.isNull(err);
178+
test('result is not an array by default', function() {
179+
client.query({ text: 'select \'hi\' as val; select \'bye\' as val;' }, assert.calls(function(err, result) {
180+
assert.isNull(err);
181+
assert.equal(result instanceof Array, false);
182+
done();
183+
}))
184+
})
185+
test('result is an array when asked', function() {
186+
client.query({ text: 'select \'hi\' as val; select \'bye\' as val;', multiResult: true }, assert.calls(function(err, results) {
187+
assert.isNull(err);
188+
assert.equal(results instanceof Array, true);
189+
assert.equal(results.length, 2);
190+
assert.equal(results[0].rows[0].val, 'hi');
191+
assert.equal(results[1].rows[0].val, 'bye');
192+
done();
193+
}))
194+
})
195+
}))
196+
})

0 commit comments

Comments
 (0)