Skip to content

Commit 6937564

Browse files
authored
chore(ecs): migrate to Assertions (#18516)
---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 132ab87 commit 6937564

22 files changed

+517
-674
lines changed

packages/@aws-cdk/aws-ecs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
},
8080
"license": "Apache-2.0",
8181
"devDependencies": {
82-
"@aws-cdk/assert-internal": "0.0.0",
82+
"@aws-cdk/assertions": "0.0.0",
8383
"@aws-cdk/aws-s3-deployment": "0.0.0",
8484
"@aws-cdk/cdk-build-tools": "0.0.0",
8585
"@aws-cdk/cdk-integ-tools": "0.0.0",

packages/@aws-cdk/aws-ecs/test/app-mesh-proxy-configuration.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import '@aws-cdk/assert-internal/jest';
1+
import { Template } from '@aws-cdk/assertions';
22
import * as cdk from '@aws-cdk/core';
33
import * as ecs from '../lib';
44

@@ -33,7 +33,7 @@ describe('app mesh proxy configuration', () => {
3333
});
3434

3535
// THEN
36-
expect(stack).toHaveResourceLike('AWS::ECS::TaskDefinition', {
36+
Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', {
3737
ProxyConfiguration: {
3838
ContainerName: 'envoy',
3939
ProxyConfigurationProperties: [
@@ -99,7 +99,7 @@ describe('app mesh proxy configuration', () => {
9999
});
100100

101101
// THEN
102-
expect(stack).toHaveResourceLike('AWS::ECS::TaskDefinition', {
102+
Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', {
103103
ProxyConfiguration: {
104104
ContainerName: 'envoy',
105105
ProxyConfigurationProperties: [
@@ -155,7 +155,7 @@ describe('app mesh proxy configuration', () => {
155155
});
156156

157157
// THEN
158-
expect(stack).toHaveResourceLike('AWS::ECS::TaskDefinition', {
158+
Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', {
159159
ProxyConfiguration: {
160160
ContainerName: 'envoy',
161161
ProxyConfigurationProperties: [

packages/@aws-cdk/aws-ecs/test/aws-log-driver.test.ts

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import '@aws-cdk/assert-internal/jest';
1+
import { Match, Template } from '@aws-cdk/assertions';
22
import * as logs from '@aws-cdk/aws-logs';
33
import * as cdk from '@aws-cdk/core';
44
import * as ecs from '../lib';
@@ -29,13 +29,13 @@ describe('aws log driver', () => {
2929
});
3030

3131
// THEN
32-
expect(stack).toHaveResource('AWS::Logs::LogGroup', {
32+
Template.fromStack(stack).hasResourceProperties('AWS::Logs::LogGroup', {
3333
RetentionInDays: logs.RetentionDays.ONE_MONTH,
3434
});
3535

36-
expect(stack).toHaveResourceLike('AWS::ECS::TaskDefinition', {
36+
Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', {
3737
ContainerDefinitions: [
38-
{
38+
Match.objectLike({
3939
LogConfiguration: {
4040
LogDriver: 'awslogs',
4141
Options: {
@@ -47,11 +47,9 @@ describe('aws log driver', () => {
4747
'mode': 'non-blocking',
4848
},
4949
},
50-
},
50+
}),
5151
],
5252
});
53-
54-
5553
});
5654

5755
test('create an aws log driver using awsLogs', () => {
@@ -67,13 +65,13 @@ describe('aws log driver', () => {
6765
});
6866

6967
// THEN
70-
expect(stack).toHaveResource('AWS::Logs::LogGroup', {
68+
Template.fromStack(stack).hasResourceProperties('AWS::Logs::LogGroup', {
7169
RetentionInDays: logs.RetentionDays.ONE_MONTH,
7270
});
7371

74-
expect(stack).toHaveResourceLike('AWS::ECS::TaskDefinition', {
72+
Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', {
7573
ContainerDefinitions: [
76-
{
74+
Match.objectLike({
7775
LogConfiguration: {
7876
LogDriver: 'awslogs',
7977
Options: {
@@ -84,11 +82,9 @@ describe('aws log driver', () => {
8482
'awslogs-multiline-pattern': 'pattern',
8583
},
8684
},
87-
},
85+
}),
8886
],
8987
});
90-
91-
9288
});
9389

9490
test('with a defined log group', () => {
@@ -105,13 +101,13 @@ describe('aws log driver', () => {
105101
});
106102

107103
// THEN
108-
expect(stack).toHaveResource('AWS::Logs::LogGroup', {
104+
Template.fromStack(stack).hasResourceProperties('AWS::Logs::LogGroup', {
109105
RetentionInDays: logs.RetentionDays.TWO_YEARS,
110106
});
111107

112-
expect(stack).toHaveResourceLike('AWS::ECS::TaskDefinition', {
108+
Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', {
113109
ContainerDefinitions: [
114-
{
110+
Match.objectLike({
115111
LogConfiguration: {
116112
LogDriver: 'awslogs',
117113
Options: {
@@ -120,11 +116,9 @@ describe('aws log driver', () => {
120116
'awslogs-region': { Ref: 'AWS::Region' },
121117
},
122118
},
123-
},
119+
}),
124120
],
125121
});
126-
127-
128122
});
129123

130124
test('without a defined log group: creates one anyway', () => {
@@ -137,9 +131,7 @@ describe('aws log driver', () => {
137131
});
138132

139133
// THEN
140-
expect(stack).toHaveResource('AWS::Logs::LogGroup', {});
141-
142-
134+
Template.fromStack(stack).hasResourceProperties('AWS::Logs::LogGroup', {});
143135
});
144136

145137
test('throws when specifying log retention and log group', () => {
@@ -172,10 +164,10 @@ describe('aws log driver', () => {
172164
});
173165

174166
// THEN
175-
expect(stack).toCountResources('AWS::Logs::LogGroup', 0);
176-
expect(stack).toHaveResourceLike('AWS::ECS::TaskDefinition', {
167+
Template.fromStack(stack).resourceCountIs('AWS::Logs::LogGroup', 0);
168+
Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', {
177169
ContainerDefinitions: [
178-
{
170+
Match.objectLike({
179171
LogConfiguration: {
180172
LogDriver: 'awslogs',
181173
Options: {
@@ -184,9 +176,8 @@ describe('aws log driver', () => {
184176
'awslogs-region': logGroupRegion,
185177
},
186178
},
187-
},
179+
}),
188180
],
189181
});
190182
});
191-
192183
});

0 commit comments

Comments
 (0)