I've written some code that connects to an FTP server and lists a very long directory. It can take 40+ seconds to get a response.
I've written some code to start testing this but I get Errored >> callback not fired.
Is there a way to instruct Vows or Node to just chill for a bit and wait for the callbacks to fire say, up to some configurable amount of time?
Here's my vows code: vows.describe('FTP Downloader Suite').addBatch({ 'FTP Downloader' : { topic: function() { var promise = new(events.EventEmitter);
var lastMomentDownloaded = moment();
lastMomentDownloaded.subtract('minute', 1);
ftpDownloader.getNewPathsToDownload(config, lastMomentDownloaded, function(err, res) {
if (err) { promise.emit('error', err, res) }
else { promise.emit('success', err, res) }
});
return promise;
},
'can be accessed': function(err, stat) {
assert.isNull(err); // we have no error
assert.isArray(stat); // we have a result
},
'is not empty': function(err, stat) {
assert.isNotZero(stat.length);
},
'is shorter than 100 paths': function(err, stat) {
assert.isTrue(stat.length < 100);
},
'contains paths matching the config': function(err, stat) {
_.each(stat, function(value, key, list) {
console.log(value);
});
}
}
}).export(module);
Thanks!
Vows was obfuscating the source of the problem which is that an error was being thrown. When I switched to nodeunit the issue was obvious. Maybe there is a way to improve error logging with vows but I'm done with it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.