Skip to content

Commit

Permalink
added integration tests for overwrite resources
Browse files Browse the repository at this point in the history
  • Loading branch information
eahefnawy committed Oct 19, 2016
1 parent f0804d2 commit b22b444
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/integration/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// General
require('./aws/general/nested-handlers/tests');
require('./aws/general/custom-resources/tests');
require('./aws/general/overwrite-resources/tests');

// API Gateway
// Integration: Lambda
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

module.exports.hello = (event, context, callback) => {
callback(null, { message: 'Go Serverless v1.0! Your function executed successfully!', event });
};

module.exports.world = (event, context, callback) => {
callback(null, { message: 'Go Serverless v1.0! Your function executed successfully!', event });
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
service: aws-nodejs # NOTE: update this with your service name

provider:
name: aws
runtime: nodejs4.3

functions:
hello:
handler: handler.hello
world:
handler: handler.world

resources:
Resources:
HelloLambdaFunction:
Type: "AWS::Lambda::Function"
Properties:
Timeout: 10
44 changes: 44 additions & 0 deletions tests/integration/aws/general/overwrite-resources/tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'use strict';

const path = require('path');
const expect = require('chai').expect;
const AWS = require('aws-sdk');
const BbPromise = require('bluebird');

const Utils = require('../../../../utils/index');

const Lambda = new AWS.Lambda({ region: 'us-east-1' });
BbPromise.promisifyAll(Lambda, { suffix: 'Promised' });

describe('AWS - General: Overwrite resources test', function () {
this.timeout(0);

let stackName;

before(() => {
stackName = Utils.createTestService('aws-nodejs', path.join(__dirname, 'service'));
Utils.deployService();
});

it('should overwrite timeout config for hello function', () => {
const helloFunctionName = `${stackName}-hello`;
return Lambda.getFunctionPromised({ FunctionName: helloFunctionName })
.then(data => {
const timeout = data.Configuration.Timeout;
expect(timeout).to.equal(10);
});
});

it('should NOT overwrite timeout config for world function', () => {
const worldFunctionName = `${stackName}-world`;
return Lambda.getFunctionPromised({ FunctionName: worldFunctionName })
.then(data => {
const timeout = data.Configuration.Timeout;
expect(timeout).to.equal(6);
});
});

after(() => {
Utils.removeService();
});
});

0 comments on commit b22b444

Please sign in to comment.