Skip to content

Commit

Permalink
updated spec
Browse files Browse the repository at this point in the history
  • Loading branch information
AkhtarAmir committed Feb 3, 2025
1 parent bfe40f9 commit 3523760
Showing 1 changed file with 7 additions and 37 deletions.
44 changes: 7 additions & 37 deletions postprocess/suppress.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,20 @@ describe('create', function () {
});

it('should return the filter if matches', function () {
var filter = suppress.create(['*:*:n*']);
expect(filter('plugin:region:name')).to.equal('*:*:n*');
var filter = suppress.create(['plugin123:us-east-1:n*']);
expect(filter('plugin123:us-east-1:name')).to.equal('plugin123:us-east-1:n*');
});

it('should return the filter if matches whole word', function () {
var filter = suppress.create(['*:*:longer']);
expect(filter('plugin:region:longer')).to.equal('*:*:longer');
var filter = suppress.create(['plugin123:us-east-1:longer']);
expect(filter('plugin123:us-east-1:longer')).to.equal('plugin123:us-east-1:longer');
});

it('should return the filter if multiple and second matches', function () {
var filter = suppress.create([
'*:*:first*',
'plugin:region:second'
'plugin123:us-east-1:first*',
'plugin456:us-west-2:second'
]);
expect(filter('plugin:region:second')).to.equal('plugin:region:second');
});

describe('validation', function() {
it('should accept valid suppression patterns', function() {
const validPatterns = [
'acmValidation:us-east-1:*',
'plugin_name:*:resource-123',
'test_plugin:region-1:certificate/123',
'*:*:*'
];
expect(() => suppress.create(validPatterns)).to.not.throw();
});

it('should reject invalid suppression formats', function() {
const invalidPatterns = [
'invalid', // Missing parts
'too:many:parts:here', // Too many parts
'invalid!:region:resource', // Invalid characters in pluginId
'plugin:reg##ion:resource', // Invalid characters in region
'plugin:region:res$$ource' // Invalid characters in resourceId
];
invalidPatterns.forEach(pattern => {
expect(() => suppress.create([pattern])).to.throw();
});
});

it('should reject overly long patterns', function() {
const longPattern = 'a'.repeat(65) + ':region:resource';
expect(() => suppress.create([longPattern])).to.throw();
});
expect(filter('plugin456:us-west-2:second')).to.equal('plugin456:us-west-2:second');
});
});

0 comments on commit 3523760

Please sign in to comment.