我写了一些连接到FTP服务器的代码,并列出了一个很长的目录。获得回复可能需要40多秒。
我已经编写了一些代码来开始测试,但我得到的是Errored>>回调未被解雇。
有没有办法指示Vows或Node只是稍微冷静一下并等待回调点火,说多达一段可配置的时间?
这是我的誓言代码: vows.describe('FTP Downloader Suite')。addBatch({ 'FTP Downloader':{ 话题: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);
谢谢!
答案 0 :(得分:0)