Skip to content

Commit

Permalink
chore(s3): migrate tests to use assertions' annotations class (#19466)
Browse files Browse the repository at this point in the history
Also removes an unnecessary dependency on having no messages on a stack, since additional messages can be introduced in the future. Related #19465.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
kaizencc committed Mar 18, 2022
1 parent c33e3eb commit 5cd1540
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/@aws-cdk/aws-s3/test/aspect.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Annotations } from '@aws-cdk/assertions';
import * as cdk from '@aws-cdk/core';
import { IConstruct } from 'constructs';
import * as s3 from '../lib';
Expand All @@ -13,9 +14,7 @@ describe('aspect', () => {
cdk.Aspects.of(stack).add(new BucketVersioningChecker());

// THEN
const assembly = app.synth().getStackArtifact(stack.artifactId);
const errorMessage = assembly.messages.find(m => m.entry.data === 'Bucket versioning is not enabled');
expect(errorMessage).toBeDefined();
Annotations.fromStack(stack).hasError('/Default/MyBucket/Resource', 'Bucket versioning is not enabled');
});

test('bucket must have versioning: success', () => {
Expand All @@ -30,8 +29,7 @@ describe('aspect', () => {
cdk.Aspects.of(stack).add(new BucketVersioningChecker());

// THEN
const assembly = app.synth().getStackArtifact(stack.artifactId);
expect(assembly.messages.length).toEqual(0);
Annotations.fromStack(stack).hasNoError('/Default/MyBucket/Resource', 'Bucket versioning is not enabled');
});
});

Expand Down

0 comments on commit 5cd1540

Please sign in to comment.