serverless-step-functions
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -17,26 +17,28 @@ 'use strict'; | ||
.then((serverlessFileParam) => { | ||
this.serverless.service.stepFunctions = {}; | ||
this.serverless.service.stepFunctions.stateMachines | ||
= serverlessFileParam.stepFunctions | ||
&& serverlessFileParam.stepFunctions.stateMachines | ||
? serverlessFileParam.stepFunctions.stateMachines : {}; | ||
this.serverless.service.stepFunctions.activities | ||
= serverlessFileParam.stepFunctions | ||
&& serverlessFileParam.stepFunctions.activities | ||
? serverlessFileParam.stepFunctions.activities : []; | ||
this.serverless.variables.populateObject(serverlessFileParam).then((parsedObject) => { | ||
this.serverless.service.stepFunctions = {}; | ||
this.serverless.service.stepFunctions.stateMachines | ||
= parsedObject.stepFunctions | ||
&& parsedObject.stepFunctions.stateMachines | ||
? parsedObject.stepFunctions.stateMachines : {}; | ||
this.serverless.service.stepFunctions.activities | ||
= parsedObject.stepFunctions | ||
&& parsedObject.stepFunctions.activities | ||
? parsedObject.stepFunctions.activities : []; | ||
if (!this.serverless.pluginManager.cliOptions.stage) { | ||
this.serverless.pluginManager.cliOptions.stage = this.options.stage | ||
if (!this.serverless.pluginManager.cliOptions.stage) { | ||
this.serverless.pluginManager.cliOptions.stage = this.options.stage | ||
|| (this.serverless.service.provider && this.serverless.service.provider.stage) | ||
|| 'dev'; | ||
} | ||
} | ||
if (!this.serverless.pluginManager.cliOptions.region) { | ||
this.serverless.pluginManager.cliOptions.region = this.options.region | ||
if (!this.serverless.pluginManager.cliOptions.region) { | ||
this.serverless.pluginManager.cliOptions.region = this.options.region | ||
|| (this.serverless.service.provider && this.serverless.service.provider.region) | ||
|| 'us-east-1'; | ||
} | ||
} | ||
this.serverless.variables.populateService(this.serverless.pluginManager.cliOptions); | ||
return BbPromise.resolve(); | ||
this.serverless.variables.populateService(this.serverless.pluginManager.cliOptions); | ||
return BbPromise.resolve(); | ||
}); | ||
}); | ||
@@ -43,0 +45,0 @@ }, |
@@ -25,5 +25,13 @@ 'use strict'; | ||
let populateServiceStub; | ||
let yamlObjectParserStub; | ||
beforeEach(() => { | ||
populateServiceStub = sinon.stub(serverlessStepFunctions.serverless.variables, | ||
'populateService').returns(BbPromise.resolve()); | ||
yamlObjectParserStub = sinon.stub(serverlessStepFunctions.serverless.variables, | ||
'populateObject').returns(BbPromise.resolve({ | ||
stepFunctions: { | ||
stateMachines: 'stepFunctions', | ||
activities: 'my-activity', | ||
}, | ||
})); | ||
yamlParserStub = sinon.stub(serverlessStepFunctions.serverless.yamlParser, 'parse') | ||
@@ -39,2 +47,8 @@ .returns(BbPromise.resolve({ | ||
afterEach(() => { | ||
serverlessStepFunctions.serverless.yamlParser.parse.restore(); | ||
serverlessStepFunctions.serverless.variables.populateService.restore(); | ||
serverlessStepFunctions.serverless.variables.populateObject.restore(); | ||
}); | ||
it('should default to dev when stage and provider are not defined', () => { | ||
@@ -79,6 +93,5 @@ serverlessStepFunctions.serverless.pluginManager.cliOptions.stage = null; | ||
expect(yamlParserStub.calledOnce).to.be.equal(false); | ||
expect(yamlObjectParserStub.calledOnce).to.be.equal(false); | ||
expect(populateServiceStub.calledOnce).to.be.equal(false); | ||
expect(serverless.service.stepFunctions).to.be.undefined; // eslint-disable-line | ||
serverlessStepFunctions.serverless.yamlParser.parse.restore(); | ||
serverlessStepFunctions.serverless.variables.populateService.restore(); | ||
}); | ||
@@ -88,10 +101,17 @@ }); | ||
it('should create corresponding when stepfunctions param are given', () => { | ||
serverlessStepFunctions.serverless.variables.populateObject.restore(); | ||
yamlObjectParserStub = sinon.stub(serverlessStepFunctions.serverless.variables, | ||
'populateObject').returns(BbPromise.resolve({ | ||
stepFunctions: { | ||
stateMachines: 'stepFunctions', | ||
activities: 'my-activity', | ||
}, | ||
})); | ||
serverlessStepFunctions.yamlParse() | ||
.then(() => { | ||
expect(yamlParserStub.calledOnce).to.be.equal(true); | ||
expect(yamlObjectParserStub.calledOnce).to.be.equal(true); | ||
expect(populateServiceStub.calledOnce).to.be.equal(true); | ||
expect(serverless.service.stepFunctions.stateMachines).to.be.equal('stepFunctions'); | ||
expect(serverless.service.stepFunctions.activities).to.be.equal('my-activity'); | ||
serverlessStepFunctions.serverless.yamlParser.parse.restore(); | ||
serverlessStepFunctions.serverless.variables.populateService.restore(); | ||
}); | ||
@@ -102,2 +122,3 @@ }); | ||
serverlessStepFunctions.serverless.yamlParser.parse.restore(); | ||
serverlessStepFunctions.serverless.variables.populateObject.restore(); | ||
yamlParserStub = sinon.stub(serverlessStepFunctions.serverless.yamlParser, 'parse') | ||
@@ -107,10 +128,13 @@ .returns(BbPromise.resolve({ | ||
})); | ||
yamlObjectParserStub = sinon.stub(serverless.variables, | ||
'populateObject').returns(BbPromise.resolve({ | ||
stepFunctions: {}, | ||
})); | ||
serverlessStepFunctions.yamlParse() | ||
.then(() => { | ||
expect(yamlParserStub.calledOnce).to.be.equal(true); | ||
expect(yamlObjectParserStub.calledOnce).to.be.equal(true); | ||
expect(populateServiceStub.calledOnce).to.be.equal(true); | ||
expect(serverless.service.stepFunctions.stateMachines).to.be.deep.equal({}); | ||
expect(serverless.service.stepFunctions.activities).to.be.deep.equal([]); | ||
serverlessStepFunctions.serverless.yamlParser.parse.restore(); | ||
serverlessStepFunctions.serverless.variables.populateService.restore(); | ||
}); | ||
@@ -117,0 +141,0 @@ }); |
{ | ||
"name": "serverless-step-functions", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "The module is AWS Step Functions plugin for Serverless Framework", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
199348
4718