Skip to content

Commit

Permalink
feat(3143): Add regex and tests for a stage setup job (#573)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThehamzaIftikhar authored Aug 6, 2024
1 parent 73a9ed7 commit 072b54c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion config/regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,7 @@ module.exports = {
// Provider Subnet ID. Can be subnet-xxxxxx, with A-Z,a-z,0-9,_
SUBNET_ID: /^subnet-[\w]+$/,
// Provider Role. Can be arn:aws:iam::xxxxxx:role/some-role
ROLE_ARN: /^arn:aws:iam::\d{12}:role\/.+/
ROLE_ARN: /^arn:aws:iam::\d{12}:role\/.+/,
// Stage setup pattern. Can be stage@stage-name:setup
STAGE_SETUP_PATTERN: /^stage@([\w-]+):setup$/
};
16 changes: 16 additions & 0 deletions test/config/regex.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,4 +508,20 @@ describe('config regex', () => {
});
});
});

describe('stageSetup', () => {
const stageSetupRegex = config.regex.STAGE_SETUP_PATTERN;

it('matches valid stage setup jobs', () => {
['stage@alpha:setup'].forEach(trigger => {
assert.isTrue(stageSetupRegex.test(trigger));
});
});

it('does not match invalid stage setup jobs', () => {
['stage@alpha:teardown', 'alpha-deploy', 'alpha:setup', 'stage@setup'].forEach(trigger => {
assert.isFalse(stageSetupRegex.test(trigger));
});
});
});
});

0 comments on commit 072b54c

Please sign in to comment.