How to use the aws-sdk-mock.setSDK function in aws-sdk-mock

To help you get started, we’ve selected a few aws-sdk-mock examples, based on popular ways it is used in public projects.

github motdotla / node-lambda / test / s3_deploy.js View on Github external
'use strict'

const { assert } = require('chai')
const path = require('path')
const aws = require('aws-sdk-mock')
aws.setSDK(path.resolve('node_modules/aws-sdk'))
const S3Deploy = require('../lib/s3_deploy')

const mockResponse = {
  createBucket: { Location: 'createBucket' },
  putObject: { ETag: 'putObject' }
}

var s3Deploy = null

/* global describe, it, before, after */
describe('lib/s3_deploy', () => {
  before(() => {
    aws.mock('S3', 'putObject', (params, callback) => {
      callback(null, mockResponse.putObject)
    })
    aws.mock('S3', 'createBucket', (params, callback) => {
github awslabs / aws-limit-monitor / source / services / tarefresh / lib / ta-refresh.spec.js View on Github external
*  or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES *
 *  OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions    *
 *  and limitations under the License.                                                                                *
 *********************************************************************************************************************/

/**
 * @author Solution Builders
 */

'use strict';

let assert = require('chai').assert;
let expect = require('chai').expect;
let path = require('path');
let AWS = require('aws-sdk-mock');
AWS.setSDK(path.resolve('./node_modules/aws-sdk'));

let TARefresh = require('./ta-refresh.js');

describe('tarefresh', function() {
  describe('#getTARefreshStatus', function() {
    let params = {};

    beforeEach(function() {});

    afterEach(function() {
      AWS.restore('Support');
    });

    it('should return success when TA refresh is successful', function(done) {
      AWS.mock('Support', 'refreshTrustedAdvisorCheck', function(
        params,
github awslabs / video-on-demand-on-aws / source / process / lib / ets-encode-hls.spec.js View on Github external
//AWS_REGION='us-east-1' mocha ingest/ingest-sns.spec.js
'use strict';

let assert = require('chai').assert;
let expect = require('chai').expect;
var path = require('path');
let AWS = require('aws-sdk-mock');
AWS.setSDK(path.resolve('./node_modules/aws-sdk'));

let lambda = require('../ets-encode-hls.js');

describe('lambda', function() {
    let _event = {
        guid: "12345678",
        srcBucket: "testBucket",
        srcVideo: "example.mpg",
        hls:[1080,720,540,360,270]
    };

    let data = {Job:{Id:1234}};

    describe('#encode-hls ', function() {

        beforeEach(function() {
github awslabs / video-on-demand-on-aws / source / encode / lib / index.spec.js View on Github external
*  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.                                           *
 *                                                                                                                    *
 *  Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance    *
 *  with the License. A copy of the License is located at                                                             *
 *                                                                                                                    *
 *      http://www.apache.org/licenses/LICENSE-2.0                                                                    *
 *                                                                                                                    *
 *  or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES *
 *  OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions    *
 *  and limitations under the License.                                                                                *
 *********************************************************************************************************************/

const expect = require('chai').expect;
const path = require('path');
const AWS = require('aws-sdk-mock');
AWS.setSDK(path.resolve('./node_modules/aws-sdk'));

const lambda = require('../index.js');

describe('#ENCODE::', () => {
    process.env.MediaConvertRole = 'Role';
    process.env.Workflow = 'vod';
    process.env.ErrorHandler = 'error_handler';

    const _event = {
        guid: '12345678',
        jobTemplate: 'jobTemplate',
        srcVideo: 'video.mp4',
        srcBucket: 'src',
        destBucket: 'dest'
    };
github awslabs / video-on-demand-on-aws / source / publish / lib / ets-publish-execute.spec.js View on Github external
//AWS_REGION='us-east-1' mocha ingest/ingest-sns.spec.js
'use strict';

let assert = require('chai').assert;
let expect = require('chai').expect;
var path = require('path');
let AWS = require('aws-sdk-mock');
AWS.setSDK(path.resolve('./node_modules/aws-sdk'));

let lambda = require('../ets-publish-execute.js');

describe('lambda', function() {
  let _event = {
    "Records": [{
      "Sns": {
        "Message": "{\"userMetadata\": {\"guid\": \"1234\",\"preset\": \"dash\"}}"
      }
    }]
  }

  describe('#handler', function() {

    beforeEach(function() {
      process.env.PublishWorkflow = 'arn:aws:states:us-east-1:::example';
github awslabs / video-on-demand-on-aws / source / step-functions / lib / index.spec.js View on Github external
*  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.                                           *
 *                                                                                                                    *
 *  Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance    *
 *  with the License. A copy of the License is located at                                                             *
 *                                                                                                                    *
 *      http://www.apache.org/licenses/LICENSE-2.0                                                                    *
 *                                                                                                                    *
 *  or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES *
 *  OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions    *
 *  and limitations under the License.                                                                                *
 *********************************************************************************************************************/

let expect = require('chai').expect;
var path = require('path');
let AWS = require('aws-sdk-mock');
AWS.setSDK(path.resolve('./node_modules/aws-sdk'));

let lambda = require('../index.js');

describe('#STEP FUNCTIONS::', () => {
    process.env.IngestWorkflow = 'INGEST';
    process.env.ProcessWorkflow = 'PROCESS';
    process.env.PublishWorkflow = 'PUBLISH';
    process.env.ErrorHandler = 'error_handler';

    let _ingest = {
        Records: [
            {
                s3: {
                    object: {
                        key: "big_bunny.mp4",
                    }
github awslabs / video-on-demand-on-aws / source / profiler / lib / index.spec.js View on Github external
*  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.                                           *
 *                                                                                                                    *
 *  Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance    *
 *  with the License. A copy of the License is located at                                                             *
 *                                                                                                                    *
 *      http://www.apache.org/licenses/LICENSE-2.0                                                                    *
 *                                                                                                                    *
 *  or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES *
 *  OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions    *
 *  and limitations under the License.                                                                                *
 *********************************************************************************************************************/

const expect = require('chai').expect;
const path = require('path');
const AWS = require('aws-sdk-mock');
AWS.setSDK(path.resolve('./node_modules/aws-sdk'));

const lambda = require('../index.js');

describe('#PROFILER::', () => {
    process.env.ErrorHandler = 'error_handler';

    const _event = {
        guid: '12345678'
    };

    const _tmpl_event = {
        guid: '12345678',
        jobTemplate: 'customTemplate'
    };

    const data = {
github awslabs / video-on-demand-on-aws / source / error-handler / lib / index.spec.js View on Github external
*  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.                                           *
 *                                                                                                                    *
 *  Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance    *
 *  with the License. A copy of the License is located at                                                             *
 *                                                                                                                    *
 *      http://www.apache.org/licenses/LICENSE-2.0                                                                    *
 *                                                                                                                    *
 *  or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES *
 *  OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions    *
 *  and limitations under the License.                                                                                *
 *********************************************************************************************************************/

let expect = require('chai').expect;
var path = require('path');
let AWS = require('aws-sdk-mock');
AWS.setSDK(path.resolve('./node_modules/aws-sdk'));

let lambda = require('../index.js');

describe('#ERROR HANDLER::', () => {
    let _lambda = {
        guid: "1234",
        error: "LAMBDA",
        function: "workflow",
    };

    let _encode = {
        guid: "12345678",
        error: "MEDIACONVERT",
        errorMessage: 'Encoding Error',
        detail: {
            jobId: '1111111',
github awslabs / video-on-demand-on-aws / source / ingest / lib / validate-source.spec.js View on Github external
'use strict';

let assert = require('chai').assert;
let expect = require('chai').expect;
var path = require('path');
let AWS = require('aws-sdk-mock');
AWS.setSDK(path.resolve('./node_modules/aws-sdk'));

let lambda = require('../validate-source.js');

describe('lambda', function() {

  let _event = {
    guid: "55ebfeba-acfc-4bce-981a-ea860595442c",
    srcVideo: "example.mpg",
    srcBucket: "bucket"
  };

  let data = {
    ContentLength: 12345
  }

  describe('#validate source ', function() {
github awslabs / video-on-demand-on-aws / source / process / lib / process-execute.spec.js View on Github external
'use strict';

let assert = require('chai').assert;
let expect = require('chai').expect;
var path = require('path');
let AWS = require('aws-sdk-mock');
AWS.setSDK(path.resolve('./node_modules/aws-sdk'));

let lambda = require('../process-execute.js');

describe('lambda', function() {
  let _event = {
      guid:"12345678",
      srcBucket:"testBucket",
      srcMetadata:"example.json"
  };

    describe('#handler', function() {

        beforeEach(function() {
          process.env.ProcessWorkflow = 'arn:aws:states:us-east-1:::example';
          process.env.ErrorHandler = "errHandler";
        });

aws-sdk-mock

Functions to mock the JavaScript aws-sdk

Apache-2.0
Latest version published 5 months ago

Package Health Score

86 / 100
Full package analysis