0

我编写了一些连接到 FTP 服务器的代码并列出了一个很长的目录。可能需要 40 多秒才能得到响应。

我已经编写了一些代码来开始测试它,但我得到 Errored >> 回调未触发。

有没有办法指示 Vows 或 Node 稍微冷静一下,然后等待回调触发,比如说,直到某个可配置的时间量?

这是我的誓言代码: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);

谢谢!

4

1 回答 1

0

Vows 混淆了问题的根源,即引发了错误。当我切换到 nodeunit 时,问题很明显。也许有一种方法可以通过誓言改进错误记录,但我已经完成了。

于 2013-11-21T20:49:20.770 回答