knex/test/tape/stream.js

24 lines
534 B
JavaScript
Raw Normal View History

2015-06-01 15:45:02 -04:00
'use strict';
var tape = require('tape')
var stream = require('stream')
2015-06-01 15:45:02 -04:00
module.exports = function(knex) {
if (knex.client.driverName === 'pg') {
tape('it streams properly in postgres', function(t) {
var w = new stream.Writable({
objectMode: true
})
w._write = function(chunk, _, next) {
setTimeout(next, 10);
}
knex.raw('select * from generate_series(0, 10, 1)').pipe(w).on('finish', function () {
2016-09-13 18:12:23 -04:00
t.ok(true, 'Streamed series');
2015-06-01 15:45:02 -04:00
t.end()
});
})
2015-06-01 15:45:02 -04:00
}
2016-09-13 18:12:23 -04:00
}