Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Commit

Permalink
make sure to delete downloaded file
Browse files Browse the repository at this point in the history
  • Loading branch information
fent committed Oct 15, 2013
1 parent c7de217 commit be74d80
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ var vows = require('vows');
var ytdl = require('..');
var fs = require('fs');
var path = require('path');
var existsSync = require('fs').existsSync;
var assert = require('assert');
var video = 'http://www.youtube.com/watch?v=90AiXO1pAiA';

Expand Down Expand Up @@ -35,7 +34,7 @@ vows.describe('download').addBatch({

assert.isObject(data);
assert.equal(data.id, '90AiXO1pAiA');
assert.equal(data.filename, 'lol-90AiXO1pAiA.flv');
assert.isTrue(/lol-90AiXO1pAiA/.test(data.filename));
assert.equal(data.size, '1.26MiB');
assert.isNumber(data.timeTakenms);
assert.isString(data.timeTaken);
Expand All @@ -46,14 +45,15 @@ vows.describe('download').addBatch({
'file was downloaded': function(err, progress, data) {
if (err) throw err;

process.nextTick(function() {
// Delete file after each test.
fs.unlink(filepath);
});

// Check existance.
var filepath = path.join(__dirname, data.filename);
assert.isTrue(existsSync(filepath));
var exists = fs.existsSync(filepath);
if (exists) {
// Delete file after each test.
fs.unlinkSync(filepath);
} else {
assert.isTrue(exists);
}
}
}
}).export(module);

0 comments on commit be74d80

Please sign in to comment.