Skip to content

Commit

Permalink
Add test case for short name
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnekaunisto committed Mar 6, 2021
1 parent f56c8c7 commit af9e731
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-stepfunctions/lib/state-machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ export class StateMachine extends StateMachineBase {
if (stateMachineName.length < 1 || stateMachineName.length > 80) {
throw new Error(`State Machine name must be between 1 and 80 characters. Received: ${stateMachineName}`);
}
if (!stateMachineName.match('^[0-9a-zA-Z\_\-]+$')) {
throw new Error(`State Machine name must match "^[0-9a-zA-Z\_\-]+$". Received: ${stateMachineName}`);
if (!stateMachineName.match('^[0-9a-zA-Z+!@._-]+$')) {
throw new Error(`State Machine name must match "^[0-9a-zA-Z+!@._-]+$". Received: ${stateMachineName}`);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,22 @@ describe('State Machine', () => {
stateMachineType: stepfunctions.StateMachineType.EXPRESS,
});
};
const tooShortName = '';
const tooLongName = 'M'.repeat(81);
const invalidCharactersName = '*';

// THEN
expect(() => {
createStateMachine(tooShortName);
}).toThrow(`State Machine name must be between 1 and 80 characters. Received: ${tooShortName}`);

expect(() => {
createStateMachine(tooLongName);
}).toThrow(`State Machine name must be between 1 and 80 characters. Received: ${tooLongName}`);

expect(() => {
createStateMachine(invalidCharactersName);
}).toThrow(`State Machine name must match "^[0-9a-zA-Z\_\-]+$". Received: ${invalidCharactersName}`);
}).toThrow(`State Machine name must match "^[0-9a-zA-Z+!@._-]+$". Received: ${invalidCharactersName}`);
});

test('log configuration', () => {
Expand Down

0 comments on commit af9e731

Please sign in to comment.