Обратный вызов не определен при вызове индекса - PullRequest
0 голосов
/ 19 апреля 2020

У меня есть индекс. js

redshiftDetails: object
sqs: object
lambda: object
redshiftQueryParams: object

module.exports = function ({ redshiftDetails, sqs, lambda, redshiftQueryParams }, callback) {
    let metrics = [];

    async.waterfall([
        async.apply(helpers.bulkReceiveFromSQS, sqs),

        /**
         * Get temporary credentials for the redshift cluster
         * @param {Array} sqsMessagesList SQS messages
         * @param {Function} callback callback function
         */
        function getRedshiftCredentials (sqsMessagesList, callback) {
            logger.info('Obtaining redshift credentials...');
...

введите описание изображения здесь

Во время написания теста я делаю:

redshiftDetails: {clusterId: 'someid', iamRole: 'somerole'}

it('should fail if the fetching temporary credentials of redshift fails', function (done) {
        stubbedGetTemporaryRedshiftCredentials.yields(new Error('call to getTemporaryRedshiftCredentials failed'));
        stubbedBulkReceiveFromSQS.yields(null);

        ingestionController({ redshiftDetails }, function (err) {
            expect(err).to.be.an('error');
            expect(err.message).to.be.equal('call to getTemporaryRedshiftCredentials failed');
            expect(stubbedRedshiftClose.callCount).to.be.equal(0);

            done();
        });
    });

Но я получаю TypeError: callback is not defined Я использую технику деструктурирования функций в своем аргументе, возможно, я что-то упускаю, но не могу найти после долгих попыток. Кто-нибудь видит здесь улов !! !! 1012 *

Stacktrace:

TypeError: callback is not a function
      at lambdas/binlogs-s3-to-redshift-ingestion-controller/lib/index.js:28:447
      at callCallback (node_modules/sinon/lib/sinon/behavior.js:101:25)
      at Object.invoke (node_modules/sinon/lib/sinon/behavior.js:145:27)
      at Object.functionStub (node_modules/sinon/lib/sinon/stub.js:127:47)
      at Function.invoke (node_modules/sinon/lib/sinon/spy.js:268:51)
      at Object.getTemporaryRedshiftCredentials (node_modules/sinon/lib/sinon/spy.js:90:30)
      at getRedshiftCredentials (lambdas/binlogs-s3-to-redshift-ingestion-controller/lib/index.js:28:193)
      at nextTask (node_modules/async/dist/async.js:5310:14)
      at next (node_modules/async/dist/async.js:5317:9)
      at node_modules/async/dist/async.js:958:16
      at callCallback (node_modules/sinon/lib/sinon/behavior.js:101:25)
      at Object.invoke (node_modules/sinon/lib/sinon/behavior.js:145:27)
      at functionStub (node_modules/sinon/lib/sinon/stub.js:127:47)
      at Function.invoke (node_modules/sinon/lib/sinon/spy.js:268:51)
      at bulkReceiveFromSQS (node_modules/sinon/lib/sinon/spy.js:90:30)
      at node_modules/async/dist/async.js:66:19
...