Skip to content

Commit

Permalink
add naming test
Browse files Browse the repository at this point in the history
  • Loading branch information
horike37 committed Apr 13, 2017
1 parent 1b9bc7f commit 43d0e32
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/deploy/stepFunctions/compileActivities.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ describe('#compileStateMachines', () => {
serverless = new Serverless();
serverless.servicePath = true;
serverless.service.service = 'step-functions';
serverless.service.provider.compiledCloudFormationTemplate = { Resources: {} };
serverless.service.provider.compiledCloudFormationTemplate = {
Resources: {},
Outputs: {},
};
serverless.setProvider('aws', new AwsProvider(serverless));
serverlessStepFunctions = new ServerlessStepFunctions(serverless);
});
Expand All @@ -40,6 +43,14 @@ describe('#compileStateMachines', () => {
.provider.compiledCloudFormationTemplate.Resources
.Activity2StepFunctionsActivity.Properties.Name
).to.equal('activity2');
expect(serverlessStepFunctions.serverless.service
.provider.compiledCloudFormationTemplate.Outputs
.Activity1StepFunctionsActivityArn.Value.Ref
).to.equal('Activity1StepFunctionsActivity');
expect(serverlessStepFunctions.serverless.service
.provider.compiledCloudFormationTemplate.Outputs
.Activity2StepFunctionsActivityArn.Value.Ref
).to.equal('Activity2StepFunctionsActivity');
});

it('should not create corresponding resources when stepfunctions are not given', () => {
Expand Down
21 changes: 20 additions & 1 deletion lib/deploy/stepFunctions/compileStateMachines.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ describe('#compileStateMachines', () => {
serverless = new Serverless();
serverless.servicePath = true;
serverless.service.service = 'step-functions';
serverless.service.provider.compiledCloudFormationTemplate = { Resources: {} };
serverless.service.provider.compiledCloudFormationTemplate = {
Resources: {},
Outputs: {},
};
serverless.setProvider('aws', new AwsProvider(serverless));
serverlessStepFunctions = new ServerlessStepFunctions(serverless);
});
Expand Down Expand Up @@ -63,6 +66,14 @@ describe('#compileStateMachines', () => {
.provider.compiledCloudFormationTemplate.Resources
.MyStateMachine2StepFunctionsStateMachine.DependsOn
).to.equal('IamRoleStateMachineExecution');
expect(serverlessStepFunctions.serverless.service
.provider.compiledCloudFormationTemplate.Outputs
.MyStateMachine1StepFunctionsStateMachineArn.Value.Ref
).to.equal('MyStateMachine1StepFunctionsStateMachine');
expect(serverlessStepFunctions.serverless.service
.provider.compiledCloudFormationTemplate.Outputs
.MyStateMachine2StepFunctionsStateMachineArn.Value.Ref
).to.equal('MyStateMachine2StepFunctionsStateMachine');
});

it('should create corresponding resources when definition and role property are given', () => {
Expand Down Expand Up @@ -104,6 +115,14 @@ describe('#compileStateMachines', () => {
.provider.compiledCloudFormationTemplate.Resources
.MyStateMachine2StepFunctionsStateMachine.Properties.RoleArn
).to.equal('arn:aws:role2');
expect(serverlessStepFunctions.serverless.service
.provider.compiledCloudFormationTemplate.Outputs
.MyStateMachine1StepFunctionsStateMachineArn.Value.Ref
).to.equal('MyStateMachine1StepFunctionsStateMachine');
expect(serverlessStepFunctions.serverless.service
.provider.compiledCloudFormationTemplate.Outputs
.MyStateMachine2StepFunctionsStateMachineArn.Value.Ref
).to.equal('MyStateMachine2StepFunctionsStateMachine');
});

it('should throw error when definition property is not given', () => {
Expand Down
14 changes: 14 additions & 0 deletions lib/naming.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,27 @@ describe('#naming', () => {
});
});

describe('#getStateMachineOutputLogicalId()', () => {
it('should normalize the stateMachine output name and add the standard suffix', () => {
expect(serverlessStepFunctions.getStateMachineOutputLogicalId('stateMachine')).to
.equal('StateMachineStepFunctionsStateMachineArn');
});
});

describe('#getActivityLogicalId()', () => {
it('should normalize the activity name and add the standard suffix', () => {
expect(serverlessStepFunctions.getActivityLogicalId('activity')).to
.equal('ActivityStepFunctionsActivity');
});
});

describe('#getActivityOutputLogicalId()', () => {
it('should normalize the activity output name and add the standard suffix', () => {
expect(serverlessStepFunctions.getActivityOutputLogicalId('activity')).to
.equal('ActivityStepFunctionsActivityArn');
});
});

describe('#getStateMachinePolicyName()', () => {
it('should use the stage and service name', () => {
expect(serverlessStepFunctions.getStateMachinePolicyName()).to
Expand Down

0 comments on commit 43d0e32

Please sign in to comment.