Skip to content

Commit 43d0e32

Browse files
committed
add naming test
1 parent 1b9bc7f commit 43d0e32

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

lib/deploy/stepFunctions/compileActivities.test.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ describe('#compileStateMachines', () => {
1313
serverless = new Serverless();
1414
serverless.servicePath = true;
1515
serverless.service.service = 'step-functions';
16-
serverless.service.provider.compiledCloudFormationTemplate = { Resources: {} };
16+
serverless.service.provider.compiledCloudFormationTemplate = {
17+
Resources: {},
18+
Outputs: {},
19+
};
1720
serverless.setProvider('aws', new AwsProvider(serverless));
1821
serverlessStepFunctions = new ServerlessStepFunctions(serverless);
1922
});
@@ -40,6 +43,14 @@ describe('#compileStateMachines', () => {
4043
.provider.compiledCloudFormationTemplate.Resources
4144
.Activity2StepFunctionsActivity.Properties.Name
4245
).to.equal('activity2');
46+
expect(serverlessStepFunctions.serverless.service
47+
.provider.compiledCloudFormationTemplate.Outputs
48+
.Activity1StepFunctionsActivityArn.Value.Ref
49+
).to.equal('Activity1StepFunctionsActivity');
50+
expect(serverlessStepFunctions.serverless.service
51+
.provider.compiledCloudFormationTemplate.Outputs
52+
.Activity2StepFunctionsActivityArn.Value.Ref
53+
).to.equal('Activity2StepFunctionsActivity');
4354
});
4455

4556
it('should not create corresponding resources when stepfunctions are not given', () => {

lib/deploy/stepFunctions/compileStateMachines.test.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ describe('#compileStateMachines', () => {
1313
serverless = new Serverless();
1414
serverless.servicePath = true;
1515
serverless.service.service = 'step-functions';
16-
serverless.service.provider.compiledCloudFormationTemplate = { Resources: {} };
16+
serverless.service.provider.compiledCloudFormationTemplate = {
17+
Resources: {},
18+
Outputs: {},
19+
};
1720
serverless.setProvider('aws', new AwsProvider(serverless));
1821
serverlessStepFunctions = new ServerlessStepFunctions(serverless);
1922
});
@@ -63,6 +66,14 @@ describe('#compileStateMachines', () => {
6366
.provider.compiledCloudFormationTemplate.Resources
6467
.MyStateMachine2StepFunctionsStateMachine.DependsOn
6568
).to.equal('IamRoleStateMachineExecution');
69+
expect(serverlessStepFunctions.serverless.service
70+
.provider.compiledCloudFormationTemplate.Outputs
71+
.MyStateMachine1StepFunctionsStateMachineArn.Value.Ref
72+
).to.equal('MyStateMachine1StepFunctionsStateMachine');
73+
expect(serverlessStepFunctions.serverless.service
74+
.provider.compiledCloudFormationTemplate.Outputs
75+
.MyStateMachine2StepFunctionsStateMachineArn.Value.Ref
76+
).to.equal('MyStateMachine2StepFunctionsStateMachine');
6677
});
6778

6879
it('should create corresponding resources when definition and role property are given', () => {
@@ -104,6 +115,14 @@ describe('#compileStateMachines', () => {
104115
.provider.compiledCloudFormationTemplate.Resources
105116
.MyStateMachine2StepFunctionsStateMachine.Properties.RoleArn
106117
).to.equal('arn:aws:role2');
118+
expect(serverlessStepFunctions.serverless.service
119+
.provider.compiledCloudFormationTemplate.Outputs
120+
.MyStateMachine1StepFunctionsStateMachineArn.Value.Ref
121+
).to.equal('MyStateMachine1StepFunctionsStateMachine');
122+
expect(serverlessStepFunctions.serverless.service
123+
.provider.compiledCloudFormationTemplate.Outputs
124+
.MyStateMachine2StepFunctionsStateMachineArn.Value.Ref
125+
).to.equal('MyStateMachine2StepFunctionsStateMachine');
107126
});
108127

109128
it('should throw error when definition property is not given', () => {

lib/naming.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,27 @@ describe('#naming', () => {
2525
});
2626
});
2727

28+
describe('#getStateMachineOutputLogicalId()', () => {
29+
it('should normalize the stateMachine output name and add the standard suffix', () => {
30+
expect(serverlessStepFunctions.getStateMachineOutputLogicalId('stateMachine')).to
31+
.equal('StateMachineStepFunctionsStateMachineArn');
32+
});
33+
});
34+
2835
describe('#getActivityLogicalId()', () => {
2936
it('should normalize the activity name and add the standard suffix', () => {
3037
expect(serverlessStepFunctions.getActivityLogicalId('activity')).to
3138
.equal('ActivityStepFunctionsActivity');
3239
});
3340
});
3441

42+
describe('#getActivityOutputLogicalId()', () => {
43+
it('should normalize the activity output name and add the standard suffix', () => {
44+
expect(serverlessStepFunctions.getActivityOutputLogicalId('activity')).to
45+
.equal('ActivityStepFunctionsActivityArn');
46+
});
47+
});
48+
3549
describe('#getStateMachinePolicyName()', () => {
3650
it('should use the stage and service name', () => {
3751
expect(serverlessStepFunctions.getStateMachinePolicyName()).to

0 commit comments

Comments
 (0)