From cc79161aa1bd097c7061296facb58f3e5261417a Mon Sep 17 00:00:00 2001 From: Philipp Muens Date: Sun, 5 Jun 2016 20:49:15 +0200 Subject: [PATCH] Rename invokeAws to awsInvoke So that it sticks to the overall used plugin naming. --- lib/plugins/Plugins.json | 2 +- .../invokeAws.js => awsInvoke/awsInvoke.js} | 4 +- .../tests/awsInvoke.js} | 90 +++++++++---------- tests/all.js | 2 +- 4 files changed, 49 insertions(+), 49 deletions(-) rename lib/plugins/{invokeAws/invokeAws.js => awsInvoke/awsInvoke.js} (98%) rename lib/plugins/{invokeAws/tests/invokeAws.js => awsInvoke/tests/awsInvoke.js} (64%) diff --git a/lib/plugins/Plugins.json b/lib/plugins/Plugins.json index 9c27a6669..45013671b 100644 --- a/lib/plugins/Plugins.json +++ b/lib/plugins/Plugins.json @@ -6,7 +6,7 @@ "./remove/remove.js", "./awsRemoveResources/awsRemoveResources.js", "./invoke/invoke.js", - "./invokeAws/invokeAws.js", + "./awsInvoke/awsInvoke.js", "./helloWorld/helloWorld.js" ] } diff --git a/lib/plugins/invokeAws/invokeAws.js b/lib/plugins/awsInvoke/awsInvoke.js similarity index 98% rename from lib/plugins/invokeAws/invokeAws.js rename to lib/plugins/awsInvoke/awsInvoke.js index 833d68146..7d4701312 100644 --- a/lib/plugins/invokeAws/invokeAws.js +++ b/lib/plugins/awsInvoke/awsInvoke.js @@ -6,7 +6,7 @@ const path = require('path'); const AWS = require('aws-sdk'); const moment = require('moment'); -class InvokeAws { +class AwsInvoke { constructor(serverless) { this.serverless = serverless; this.options = {}; @@ -126,4 +126,4 @@ class InvokeAws { } } -module.exports = InvokeAws; +module.exports = AwsInvoke; diff --git a/lib/plugins/invokeAws/tests/invokeAws.js b/lib/plugins/awsInvoke/tests/awsInvoke.js similarity index 64% rename from lib/plugins/invokeAws/tests/invokeAws.js rename to lib/plugins/awsInvoke/tests/awsInvoke.js index eed0d5e46..5bcee179d 100644 --- a/lib/plugins/invokeAws/tests/invokeAws.js +++ b/lib/plugins/awsInvoke/tests/awsInvoke.js @@ -4,34 +4,34 @@ const expect = require('chai').expect; const sinon = require('sinon'); const path = require('path'); const os = require('os'); -const InvokeAws = require('../invokeAws'); +const AwsInvoke = require('../awsInvoke'); const Serverless = require('../../../Serverless'); const BbPromise = require('bluebird'); const AWS = require('aws-sdk'); const serverless = new Serverless(); -const invokeAws = new InvokeAws(serverless); +const awsInvoke = new AwsInvoke(serverless); -describe('InvokeAws', () => { +describe('awsInvoke', () => { describe('#constructor()', () => { - it('should have hooks', () => expect(invokeAws.hooks).to.be.not.empty); + it('should have hooks', () => expect(awsInvoke.hooks).to.be.not.empty); it('should run promise chain in order', () => { const validateStub = sinon - .stub(invokeAws, 'validate').returns(BbPromise.resolve()); + .stub(awsInvoke, 'validate').returns(BbPromise.resolve()); const invokeStub = sinon - .stub(invokeAws, 'invoke').returns(BbPromise.resolve()); + .stub(awsInvoke, 'invoke').returns(BbPromise.resolve()); const logStub = sinon - .stub(invokeAws, 'log').returns(BbPromise.resolve()); + .stub(awsInvoke, 'log').returns(BbPromise.resolve()); - return invokeAws.hooks['invoke:invoke']().then(() => { + return awsInvoke.hooks['invoke:invoke']().then(() => { expect(validateStub.calledOnce).to.be.equal(true); expect(invokeStub.calledAfter(validateStub)).to.be.equal(true); expect(logStub.calledAfter(invokeStub)).to.be.equal(true); - invokeAws.validate.restore(); - invokeAws.invoke.restore(); - invokeAws.log.restore(); + awsInvoke.validate.restore(); + awsInvoke.invoke.restore(); + awsInvoke.log.restore(); }); }); }); @@ -57,15 +57,15 @@ describe('InvokeAws', () => { handler: true, }, }; - invokeAws.options = { + awsInvoke.options = { stage: 'dev', region: 'us-east-1', function: 'hello', }; }); - it('it should resolve if all config is valid', () => invokeAws.validate() - .then(() => expect(typeof invokeAws.Lambda).to.not.be.equal('undefined')) + it('it should resolve if all config is valid', () => awsInvoke.validate() + .then(() => expect(typeof awsInvoke.Lambda).to.not.be.equal('undefined')) ); it('it should parse file if file path is provided', () => { @@ -75,43 +75,43 @@ describe('InvokeAws', () => { }; serverless.utils.writeFileSync(path .join(serverless.config.servicePath, 'data.json'), JSON.stringify(data)); - invokeAws.options.path = 'data.json'; - return invokeAws.validate().then(() => { - expect(invokeAws.options.data).to.deep.equal(data); - invokeAws.options.path = false; + awsInvoke.options.path = 'data.json'; + return awsInvoke.validate().then(() => { + expect(awsInvoke.options.data).to.deep.equal(data); + awsInvoke.options.path = false; serverless.config.servicePath = true; }); }); it('it should throw error if function is missing', () => { - invokeAws.options.function = false; - expect(() => invokeAws.validate()).to.throw(Error); - invokeAws.options.function = 'hello'; + awsInvoke.options.function = false; + expect(() => awsInvoke.validate()).to.throw(Error); + awsInvoke.options.function = 'hello'; }); it('it should throw error if stage is missing', () => { - invokeAws.options.stage = null; - expect(() => invokeAws.validate()).to.throw(Error); - invokeAws.options.stage = 'dev'; + awsInvoke.options.stage = null; + expect(() => awsInvoke.validate()).to.throw(Error); + awsInvoke.options.stage = 'dev'; }); it('it should throw error if region is missing', () => { - invokeAws.options.region = null; - expect(() => invokeAws.validate()).to.throw(Error); - invokeAws.options.region = 'us-east-1'; + awsInvoke.options.region = null; + expect(() => awsInvoke.validate()).to.throw(Error); + awsInvoke.options.region = 'us-east-1'; }); it('it should throw error if service path is not set', () => { serverless.config.servicePath = false; - expect(() => invokeAws.validate()).to.throw(Error); + expect(() => awsInvoke.validate()).to.throw(Error); serverless.config.servicePath = true; }); it('it should throw error if file path does not exist', () => { serverless.config.servicePath = path.join(os.tmpdir(), (new Date).getTime().toString()); - invokeAws.options.path = 'some/path'; - expect(() => invokeAws.validate()).to.throw(Error); - invokeAws.options.path = false; + awsInvoke.options.path = 'some/path'; + expect(() => awsInvoke.validate()).to.throw(Error); + awsInvoke.options.path = false; serverless.config.servicePath = true; }); }); @@ -119,48 +119,48 @@ describe('InvokeAws', () => { describe('#invoke()', () => { let invokeStub; beforeEach(() => { - invokeAws.Lambda = new AWS.Lambda({ region: 'us-east-1' }); - BbPromise.promisifyAll(invokeAws.Lambda, { suffix: 'Promised' }); - invokeAws.serverless.service.service = 'new-service'; - invokeAws.options = { + awsInvoke.Lambda = new AWS.Lambda({ region: 'us-east-1' }); + BbPromise.promisifyAll(awsInvoke.Lambda, { suffix: 'Promised' }); + awsInvoke.serverless.service.service = 'new-service'; + awsInvoke.options = { function: 'hello', }; - invokeStub = sinon.stub(invokeAws.Lambda, 'invokePromised').returns(BbPromise.resolve()); + invokeStub = sinon.stub(awsInvoke.Lambda, 'invokePromised').returns(BbPromise.resolve()); }); - it('should invoke with correct params', () => invokeAws.invoke() + it('should invoke with correct params', () => awsInvoke.invoke() .then(() => { expect(invokeStub.calledOnce).to.be.equal(true); expect(invokeStub.args[0][0].FunctionName).to.be.equal('new-service-hello'); expect(invokeStub.args[0][0].InvocationType).to.be.equal('RequestResponse'); expect(invokeStub.args[0][0].LogType).to.be.equal('None'); expect(typeof invokeStub.args[0][0].Payload).to.not.be.equal('undefined'); - invokeAws.Lambda.invokePromised.restore(); + awsInvoke.Lambda.invokePromised.restore(); }) ); it('should invoke and log', () => { - invokeAws.options.log = true; - return invokeAws.invoke().then(() => { + awsInvoke.options.log = true; + return awsInvoke.invoke().then(() => { expect(invokeStub.calledOnce).to.be.equal(true); expect(invokeStub.args[0][0].FunctionName).to.be.equal('new-service-hello'); expect(invokeStub.args[0][0].InvocationType).to.be.equal('RequestResponse'); expect(invokeStub.args[0][0].LogType).to.be.equal('Tail'); expect(typeof invokeStub.args[0][0].Payload).to.not.be.equal('undefined'); - invokeAws.Lambda.invokePromised.restore(); + awsInvoke.Lambda.invokePromised.restore(); }); }); it('should invoke with other invocation type', () => { - invokeAws.options.type = 'OtherType'; - return invokeAws.invoke().then(() => { + awsInvoke.options.type = 'OtherType'; + return awsInvoke.invoke().then(() => { expect(invokeStub.calledOnce).to.be.equal(true); expect(invokeStub.args[0][0].FunctionName).to.be.equal('new-service-hello'); expect(invokeStub.args[0][0].InvocationType).to.be.equal('OtherType'); expect(invokeStub.args[0][0].LogType).to.be.equal('None'); expect(typeof invokeStub.args[0][0].Payload).to.not.be.equal('undefined'); - invokeAws.Lambda.invokePromised.restore(); + awsInvoke.Lambda.invokePromised.restore(); }); }); }); @@ -176,7 +176,7 @@ describe('InvokeAws', () => { LogResult: 'test', }; - return invokeAws.log(invocationReplyMock); + return awsInvoke.log(invocationReplyMock); }); }); }); diff --git a/tests/all.js b/tests/all.js index b9fe409a0..f8a8a368b 100644 --- a/tests/all.js +++ b/tests/all.js @@ -22,4 +22,4 @@ require('../lib/plugins/remove/tests/remove'); require('../lib/plugins/awsDeploy/tests/all'); require('../lib/plugins/awsRemoveResources/tests/all'); require('../lib/plugins/invoke/tests/invoke'); -require('../lib/plugins/invokeAws/tests/invokeAws'); +require('../lib/plugins/awsInvoke/tests/awsInvoke');