Skip to content

Commit e92203b

Browse files
author
Chris Sullivan
committed
-_- adding tests, more lint fixes
1 parent b1a3025 commit e92203b

File tree

4 files changed

+65
-2
lines changed

4 files changed

+65
-2
lines changed

lib/deploy/stepFunctions/compileStateMachines.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
let DependsOn;
1313
let Name;
1414

15-
if (stateMachineObj.hasOwnProperty('Name')) {
15+
if (stateMachineObj.Name) {
1616
Name = stateMachineObj.Name;
1717
}
1818

lib/deploy/stepFunctions/compileStateMachines.test.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,55 @@ describe('#compileStateMachines', () => {
7676
).to.equal('MyStateMachine2StepFunctionsStateMachine');
7777
});
7878

79+
it('should create named resources when Name is provided', () => {
80+
serverless.service.stepFunctions = {
81+
stateMachines: {
82+
myStateMachine1: {
83+
definition: 'definition1',
84+
Name: 'stateMachineBeta1',
85+
},
86+
myStateMachine2: {
87+
definition: 'definition2',
88+
Name: 'stateMachineBeta2',
89+
},
90+
},
91+
};
92+
93+
serverlessStepFunctions.compileStateMachines();
94+
expect(serverlessStepFunctions.serverless.service
95+
.provider.compiledCloudFormationTemplate.Resources
96+
.StateMachineBeta1.Type
97+
).to.equal('AWS::StepFunctions::StateMachine');
98+
expect(serverlessStepFunctions.serverless.service
99+
.provider.compiledCloudFormationTemplate.Resources
100+
.StateMachineBeta2.Type
101+
).to.equal('AWS::StepFunctions::StateMachine');
102+
expect(serverlessStepFunctions.serverless.service
103+
.provider.compiledCloudFormationTemplate.Resources
104+
.StateMachineBeta1.Properties.DefinitionString
105+
).to.equal('"definition1"');
106+
expect(serverlessStepFunctions.serverless.service
107+
.provider.compiledCloudFormationTemplate.Resources
108+
.StateMachineBeta2.Properties.DefinitionString
109+
).to.equal('"definition2"');
110+
expect(serverlessStepFunctions.serverless.service
111+
.provider.compiledCloudFormationTemplate.Resources
112+
.StateMachineBeta1.Properties.RoleArn['Fn::GetAtt'][0]
113+
).to.equal('IamRoleStateMachineExecution');
114+
expect(serverlessStepFunctions.serverless.service
115+
.provider.compiledCloudFormationTemplate.Resources
116+
.StateMachineBeta2.Properties.RoleArn['Fn::GetAtt'][0]
117+
).to.equal('IamRoleStateMachineExecution');
118+
expect(serverlessStepFunctions.serverless.service
119+
.provider.compiledCloudFormationTemplate.Resources
120+
.StateMachineBeta1.DependsOn
121+
).to.equal('IamRoleStateMachineExecution');
122+
expect(serverlessStepFunctions.serverless.service
123+
.provider.compiledCloudFormationTemplate.Resources
124+
.StateMachineBeta2.DependsOn
125+
).to.equal('IamRoleStateMachineExecution');
126+
});
127+
79128
it('should create corresponding resources when definition and role property are given', () => {
80129
serverless.service.stepFunctions = {
81130
stateMachines: {

lib/naming.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = {
1111

1212
getStateMachineOutputLogicalId(stateMachineName, Name) {
1313
if (Name) {
14-
return `${this.provider.naming.getNormalizedFunctionName(Name)}`;
14+
return `${this.provider.naming.getNormalizedFunctionName(Name)}Arn`;
1515
}
1616
return `${this.provider.naming
1717
.getNormalizedFunctionName(stateMachineName)}StepFunctionsStateMachineArn`;

lib/naming.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ describe('#naming', () => {
3232
});
3333
});
3434

35+
describe('#getStateMachineLogicalId() -- Named', () => {
36+
it('should normalize the stateMachine name and add the standard suffix', () => {
37+
expect(serverlessStepFunctions.getStateMachineLogicalId('stateMachine', 'alphaNumeric')).to
38+
.equal('AlphaNumeric');
39+
});
40+
});
41+
42+
describe('#getStateMachineOutputLogicalId() -- Named', () => {
43+
it('should normalize the stateMachine output name and add the standard suffix', () => {
44+
expect(serverlessStepFunctions.getStateMachineOutputLogicalId('stateMachine', 'alphaNumeric'))
45+
.to.equal('AlphaNumericArn');
46+
});
47+
});
48+
3549
describe('#getActivityLogicalId()', () => {
3650
it('should normalize the activity name and add the standard suffix', () => {
3751
expect(serverlessStepFunctions.getActivityLogicalId('activity')).to

0 commit comments

Comments
 (0)