|
1 | 1 | import { Construct } from 'constructs';
|
2 | 2 | import { toCloudFormation } from './util';
|
3 |
| -import { CfnResource, CfnResourceProps, RemoveTag, Stack, Tag, TagManager, TagType, Aspects, Tags, ITaggable, ITaggableV2 } from '../lib'; |
| 3 | +import { |
| 4 | + CfnResource, |
| 5 | + CfnResourceProps, |
| 6 | + RemoveTag, |
| 7 | + Stack, |
| 8 | + Tag, |
| 9 | + TagManager, |
| 10 | + TagType, |
| 11 | + Aspects, |
| 12 | + Tags, |
| 13 | + ITaggable, |
| 14 | + ITaggableV2, |
| 15 | + AspectPriority, |
| 16 | +} from '../lib'; |
4 | 17 | import { synthesize } from '../lib/private/synthesis';
|
5 | 18 |
|
6 | 19 | class TaggableResource extends CfnResource implements ITaggable {
|
@@ -131,6 +144,23 @@ describe('tag aspect', () => {
|
131 | 144 | expect(res2.tags.renderTags()).toEqual([{ key: 'first', value: 'there is only 1' }]);
|
132 | 145 | });
|
133 | 146 |
|
| 147 | + test('Tags applied without priority get mutating priority value', () => { |
| 148 | + const root = new Stack(); |
| 149 | + const res = new TaggableResource(root, 'FakeResource', { |
| 150 | + type: 'AWS::Fake::Thing', |
| 151 | + }); |
| 152 | + |
| 153 | + Tags.of(root).add('root', 'was here'); |
| 154 | + Tags.of(res).add('first', 'there is only 1'); |
| 155 | + Tags.of(res).remove('root'); |
| 156 | + |
| 157 | + const rootAspectApplications = Aspects.of(root).applied; |
| 158 | + expect(rootAspectApplications[0].priority).toEqual(AspectPriority.MUTATING); |
| 159 | + const resAspectApplications = Aspects.of(res).applied; |
| 160 | + expect(resAspectApplications[0].priority).toEqual(AspectPriority.MUTATING); |
| 161 | + expect(resAspectApplications[1].priority).toEqual(AspectPriority.MUTATING); |
| 162 | + }); |
| 163 | + |
134 | 164 | test('add will add a tag and remove will remove a tag if it exists', () => {
|
135 | 165 | const root = new Stack();
|
136 | 166 | const res = new TaggableResource(root, 'FakeResource', {
|
|
0 commit comments