Skip to content

Commit

Permalink
test for optional transform stream
Browse files Browse the repository at this point in the history
  • Loading branch information
rclark committed Jun 25, 2015
1 parent 3613938 commit f91ff26
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/copy.test.js
@@ -1,5 +1,6 @@
var test = require('tape');
var fs = require('fs');
var stream = require('stream');
var tmp = require('os').tmpdir();
var path = require('path');
var exec = require('child_process').exec;
Expand Down Expand Up @@ -318,6 +319,24 @@ test('tilelive.copy timeout', function(t) {
});
});

test('tilelive.copy transform', function(t) {
var src = __dirname + '/fixtures/plain_1.mbtiles';
var dst = path.join(tmp, crypto.randomBytes(12).toString('hex') + '.tilelivecopy.mbtiles');
var transform = new stream.Transform({ objectMode: true });
var count = 0;
transform._transform = function(tile, enc, callback) {
count++;
transform.push(tile);
callback();
};

tilelive.copy(src, dst, { transform: transform }, function(err){
t.ifError(err, 'success');
t.equal(count, 286, 'tiles were passed through transform stream');
t.end();
});
});

// Used for progress report
function report(stats, p) {
util.print(util.format('\r\033[K[%s] %s%% %s/%s @ %s/s | ✓ %s □ %s | %s left',
Expand Down

0 comments on commit f91ff26

Please sign in to comment.