@mapbox/cloudfriend 9.2.0-0 → 9.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/changelog.md +8 -0
  2. package/coverage/clover.xml +598 -0
  3. package/coverage/coverage-final.json +32 -0
  4. package/coverage/lcov-report/base.css +224 -0
  5. package/coverage/lcov-report/block-navigation.js +87 -0
  6. package/coverage/lcov-report/cloudfriend/bin/build-template.js.html +130 -0
  7. package/coverage/lcov-report/cloudfriend/bin/index.html +131 -0
  8. package/coverage/lcov-report/cloudfriend/bin/validate-template.js.html +142 -0
  9. package/coverage/lcov-report/cloudfriend/index.html +116 -0
  10. package/coverage/lcov-report/cloudfriend/index.js.html +307 -0
  11. package/coverage/lcov-report/cloudfriend/lib/build.js.html +217 -0
  12. package/coverage/lcov-report/cloudfriend/lib/conditions.js.html +430 -0
  13. package/coverage/lcov-report/cloudfriend/lib/index.html +206 -0
  14. package/coverage/lcov-report/cloudfriend/lib/intrinsic.js.html +979 -0
  15. package/coverage/lcov-report/cloudfriend/lib/merge.js.html +478 -0
  16. package/coverage/lcov-report/cloudfriend/lib/pseudo.js.html +370 -0
  17. package/coverage/lcov-report/cloudfriend/lib/rules.js.html +349 -0
  18. package/coverage/lcov-report/cloudfriend/lib/shortcuts/cross-account-role.js.html +244 -0
  19. package/coverage/lcov-report/cloudfriend/lib/shortcuts/event-lambda.js.html +367 -0
  20. package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-database.js.html +286 -0
  21. package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-json-table.js.html +235 -0
  22. package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-orc-table.js.html +226 -0
  23. package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-parquet-table.js.html +268 -0
  24. package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-presto-view.js.html +358 -0
  25. package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-spark-view.js.html +241 -0
  26. package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-table.js.html +481 -0
  27. package/coverage/lcov-report/cloudfriend/lib/shortcuts/hookshot.js.html +1504 -0
  28. package/coverage/lcov-report/cloudfriend/lib/shortcuts/index.html +416 -0
  29. package/coverage/lcov-report/cloudfriend/lib/shortcuts/index.js.html +154 -0
  30. package/coverage/lcov-report/cloudfriend/lib/shortcuts/kinesis-firehose-base.js.html +418 -0
  31. package/coverage/lcov-report/cloudfriend/lib/shortcuts/lambda.js.html +832 -0
  32. package/coverage/lcov-report/cloudfriend/lib/shortcuts/log-subscription-lambda.js.html +310 -0
  33. package/coverage/lcov-report/cloudfriend/lib/shortcuts/queue-lambda.js.html +364 -0
  34. package/coverage/lcov-report/cloudfriend/lib/shortcuts/queue.js.html +619 -0
  35. package/coverage/lcov-report/cloudfriend/lib/shortcuts/role.js.html +382 -0
  36. package/coverage/lcov-report/cloudfriend/lib/shortcuts/s3-kinesis-firehose.js.html +568 -0
  37. package/coverage/lcov-report/cloudfriend/lib/shortcuts/scheduled-lambda.js.html +490 -0
  38. package/coverage/lcov-report/cloudfriend/lib/shortcuts/service-role.js.html +307 -0
  39. package/coverage/lcov-report/cloudfriend/lib/shortcuts/stream-lambda.js.html +493 -0
  40. package/coverage/lcov-report/cloudfriend/lib/validate.js.html +154 -0
  41. package/coverage/lcov-report/favicon.png +0 -0
  42. package/coverage/lcov-report/index.html +161 -0
  43. package/coverage/lcov-report/prettify.css +1 -0
  44. package/coverage/lcov-report/prettify.js +2 -0
  45. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  46. package/coverage/lcov-report/sorter.js +210 -0
  47. package/coverage/lcov.info +1240 -0
  48. package/jest.config.js +14 -0
  49. package/lib/shortcuts/api.md +1 -0
  50. package/lib/shortcuts/lambda.js +4 -2
  51. package/package.json +15 -13
  52. package/readme.md +1 -1
  53. package/test/bin.test.js +18 -14
  54. package/test/fixtures/shortcuts/cross-account-role-defaults.json +1 -1
  55. package/test/fixtures/shortcuts/cross-account-role-no-defaults.json +1 -1
  56. package/test/fixtures/shortcuts/event-lambda-defaults.json +3 -1
  57. package/test/fixtures/shortcuts/event-lambda-full.json +3 -1
  58. package/test/fixtures/shortcuts/firehose-defaults.json +1 -1
  59. package/test/fixtures/shortcuts/firehose-with-stream.json +1 -1
  60. package/test/fixtures/shortcuts/glue-database-defaults.json +1 -1
  61. package/test/fixtures/shortcuts/glue-database-no-defaults.json +1 -1
  62. package/test/fixtures/shortcuts/glue-json-table-defaults.json +1 -1
  63. package/test/fixtures/shortcuts/glue-json-table-no-defaults.json +1 -1
  64. package/test/fixtures/shortcuts/glue-orc-table-defaults.json +1 -1
  65. package/test/fixtures/shortcuts/glue-orc-table-no-defaults.json +1 -1
  66. package/test/fixtures/shortcuts/glue-parquet-table-defaults.json +1 -1
  67. package/test/fixtures/shortcuts/glue-parquet-table-no-defaults.json +1 -1
  68. package/test/fixtures/shortcuts/glue-table-defaults.json +1 -1
  69. package/test/fixtures/shortcuts/glue-table-no-defaults.json +1 -1
  70. package/test/fixtures/shortcuts/glue-view-defaults.json +1 -1
  71. package/test/fixtures/shortcuts/glue-view-no-defaults.json +1 -1
  72. package/test/fixtures/shortcuts/hookshot-github-secret-ref.json +8 -4
  73. package/test/fixtures/shortcuts/hookshot-github-secret-string.json +8 -4
  74. package/test/fixtures/shortcuts/hookshot-github.json +8 -4
  75. package/test/fixtures/shortcuts/hookshot-passthrough-access-log-format.json +8 -4
  76. package/test/fixtures/shortcuts/hookshot-passthrough-alarms.json +8 -4
  77. package/test/fixtures/shortcuts/hookshot-passthrough-enhanced-logging.json +8 -4
  78. package/test/fixtures/shortcuts/hookshot-passthrough-full-blown-logging.json +8 -4
  79. package/test/fixtures/shortcuts/hookshot-passthrough-logging.json +8 -4
  80. package/test/fixtures/shortcuts/hookshot-passthrough.json +8 -4
  81. package/test/fixtures/shortcuts/lambda-defaults.json +3 -1
  82. package/test/fixtures/shortcuts/lambda-docker.json +3 -1
  83. package/test/fixtures/shortcuts/lambda-full.json +3 -1
  84. package/test/fixtures/shortcuts/lambda-provided-role.json +3 -1
  85. package/test/fixtures/shortcuts/lambda-zipfile.json +3 -1
  86. package/test/fixtures/shortcuts/log-subscription-lambda-defaults.json +3 -1
  87. package/test/fixtures/shortcuts/log-subscription-lambda-no-defaults.json +3 -1
  88. package/test/fixtures/shortcuts/queue-defaults.json +1 -1
  89. package/test/fixtures/shortcuts/queue-external-topic-ref.json +1 -1
  90. package/test/fixtures/shortcuts/queue-external-topic.json +1 -1
  91. package/test/fixtures/shortcuts/queue-fifo-queuename.json +1 -1
  92. package/test/fixtures/shortcuts/queue-fifo.json +1 -1
  93. package/test/fixtures/shortcuts/queue-full.json +1 -1
  94. package/test/fixtures/shortcuts/queue-lambda-zero.json +3 -1
  95. package/test/fixtures/shortcuts/queue-lambda.json +3 -1
  96. package/test/fixtures/shortcuts/role-defaults.json +1 -1
  97. package/test/fixtures/shortcuts/role-no-defaults.json +1 -1
  98. package/test/fixtures/shortcuts/scheduled-lambda-defaults.json +3 -1
  99. package/test/fixtures/shortcuts/scheduled-lambda-full.json +3 -1
  100. package/test/fixtures/shortcuts/service-role-defaults.json +1 -1
  101. package/test/fixtures/shortcuts/service-role-no-defaults.json +1 -1
  102. package/test/fixtures/shortcuts/service-role-no-url-suffix.json +1 -1
  103. package/test/fixtures/shortcuts/service-role-url-suffix-with-replacement.json +1 -1
  104. package/test/fixtures/shortcuts/service-role-url-suffix.json +1 -1
  105. package/test/fixtures/shortcuts/stream-lambda-defaults.json +3 -1
  106. package/test/fixtures/shortcuts/stream-lambda-no-defaults.json +3 -1
  107. package/test/index.test.js +383 -235
  108. package/test/shortcuts.test.js +1227 -1462
  109. package/.nyc_output/0030e99c-2d96-4ac6-a2b2-bffd93da01bc.json +0 -1
  110. package/.nyc_output/e1868cff-0dd0-46eb-866d-70c3b666dae8.json +0 -1
  111. package/.nyc_output/processinfo/0030e99c-2d96-4ac6-a2b2-bffd93da01bc.json +0 -1
  112. package/.nyc_output/processinfo/e1868cff-0dd0-46eb-866d-70c3b666dae8.json +0 -1
  113. package/.nyc_output/processinfo/index.json +0 -1
@@ -3,7 +3,6 @@
3
3
  const cp = require('child_process');
4
4
  const path = require('path');
5
5
  const fs = require('fs');
6
- const test = require('tape');
7
6
  const cf = require('..');
8
7
  const fixtures = require('./fixtures/shortcuts');
9
8
  const util = require('util');
@@ -13,7 +12,7 @@ const update = !!process.env.UPDATE;
13
12
 
14
13
  const noUndefined = (template) => JSON.parse(JSON.stringify(template));
15
14
 
16
- test('[shortcuts] fixture validation', async (assert) => {
15
+ describe('[shortcuts] fixture validation', () => {
17
16
  // Runs cfn-lint, ignoring "warnings". Install via pip or Homebrew to run these
18
17
  // tests locally.
19
18
  const cfnLint = (filepath) => new Promise((resolve, reject) => {
@@ -27,36 +26,25 @@ test('[shortcuts] fixture validation', async (assert) => {
27
26
  .readdirSync(path.join(__dirname, 'fixtures', 'shortcuts'))
28
27
  .filter((filename) => path.extname(filename) === '.json');
29
28
 
30
- while (toValidate.length) {
31
- const filename = toValidate.shift();
29
+ test.each(toValidate)('%s fixture passes validation', async (filename) => {
32
30
  await Promise.all([
33
- cfnLint(path.join(__dirname, 'fixtures', 'shortcuts', filename))
34
- .then(() => assert.pass(`${filename} fixture passed validation`))
35
- .catch((err) => {
36
- assert.fail(`${filename} fixture fails validation`);
37
- console.log(err.message);
38
- }),
31
+ cfnLint(path.join(__dirname, 'fixtures', 'shortcuts', filename)),
39
32
  sleep(1000)
40
33
  ]);
41
- }
42
-
43
- assert.end();
34
+ });
44
35
  });
45
36
 
46
- test('[shortcuts] lambda', (assert) => {
47
- assert.throws(
48
- () => new cf.shortcuts.Lambda(),
49
- 'Options required',
50
- 'throws without options'
51
- );
52
- assert.throws(
53
- () => new cf.shortcuts.Lambda({}),
54
- /You must provide a LogicalName, and Code/,
55
- 'throws without required parameters'
56
- );
37
+ describe('[shortcuts] lambda', () => {
38
+ test('throws without options', () => {
39
+ expect(() => new cf.shortcuts.Lambda()).toThrow('Options required');
40
+ });
41
+
42
+ test('throws without required parameters', () => {
43
+ expect(() => new cf.shortcuts.Lambda({})).toThrow(/You must provide a LogicalName, and Code/);
44
+ });
57
45
 
58
- assert.throws(
59
- () => new cf.shortcuts.Lambda({
46
+ test('throws for RoleArn and Statements both provided', () => {
47
+ expect(() => new cf.shortcuts.Lambda({
60
48
  LogicalName: 'MyLambda',
61
49
  Code: {
62
50
  S3Bucket: 'my-code-bucket',
@@ -68,453 +56,400 @@ test('[shortcuts] lambda', (assert) => {
68
56
  Action: 's3:GetObject',
69
57
  Resource: 'arn:aws:s3:::my-bucket/*'
70
58
  }]
71
- }),
72
- /You cannot specify both Statements and a RoleArn/,
73
- 'throws for RoleArn and Statements both provided'
74
- );
75
-
76
- let lambda = new cf.shortcuts.Lambda({
77
- LogicalName: 'MyLambda',
78
- Code: {
79
- S3Bucket: 'my-code-bucket',
80
- S3Key: 'path/to/code.zip'
81
- }
59
+ })).toThrow(/You cannot specify both Statements and a RoleArn/);
82
60
  });
83
61
 
84
- let template = cf.merge(lambda);
85
- if (update) fixtures.update('lambda-defaults', template);
86
- assert.deepEqual(
87
- noUndefined(template),
88
- fixtures.get('lambda-defaults'),
89
- 'expected resources generated using all default values'
90
- );
62
+ test('expected resources generated using all default values', () => {
63
+ const lambda = new cf.shortcuts.Lambda({
64
+ LogicalName: 'MyLambda',
65
+ Code: {
66
+ S3Bucket: 'my-code-bucket',
67
+ S3Key: 'path/to/code.zip'
68
+ }
69
+ });
91
70
 
92
- const lambdaWithRetain = new cf.shortcuts.Lambda({
93
- LogicalName: 'MyLambda',
94
- Code: { S3Bucket: 'my-code-bucket', S3Key: 'path/to/code.zip' },
95
- LogPolicyDeletionPolicy: 'Retain'
71
+ const template = cf.merge(lambda);
72
+ if (update) fixtures.update('lambda-defaults', template);
73
+ expect(noUndefined(template)).toEqual(fixtures.get('lambda-defaults'));
96
74
  });
97
- const templateWithRetain = cf.merge(lambdaWithRetain);
98
- assert.equal(
99
- templateWithRetain.Resources.MyLambdaLogPolicy.DeletionPolicy,
100
- 'Retain',
101
- 'LogPolicyDeletionPolicy=Retain sets DeletionPolicy on IAM Policy resource'
102
- );
103
75
 
104
- lambda = new cf.shortcuts.Lambda({
105
- LogicalName: 'MyLambda',
106
- Code: {
107
- ImageUri: 'MyImage'
108
- }
76
+ test('LogPolicyDeletionPolicy=Retain sets DeletionPolicy on IAM Policy resource', () => {
77
+ const lambdaWithRetain = new cf.shortcuts.Lambda({
78
+ LogicalName: 'MyLambda',
79
+ Code: { S3Bucket: 'my-code-bucket', S3Key: 'path/to/code.zip' },
80
+ LogPolicyDeletionPolicy: 'Retain'
81
+ });
82
+ const templateWithRetain = cf.merge(lambdaWithRetain);
83
+ expect(templateWithRetain.Resources.MyLambdaLogPolicy.DeletionPolicy).toBe('Retain');
109
84
  });
110
85
 
111
- template = cf.merge(lambda);
112
- if (update) fixtures.update('lambda-docker', template);
113
- assert.deepEqual(
114
- noUndefined(template),
115
- fixtures.get('lambda-docker'),
116
- 'expected resources generated using all default values and a docker image'
117
- );
86
+ test('expected resources generated using all default values and a docker image', () => {
87
+ const lambda = new cf.shortcuts.Lambda({
88
+ LogicalName: 'MyLambda',
89
+ Code: {
90
+ ImageUri: 'MyImage'
91
+ }
92
+ });
118
93
 
119
- lambda = new cf.shortcuts.Lambda({
120
- LogicalName: 'MyLambda',
121
- Code: {
122
- ZipFile: 'fake code'
123
- }
94
+ const template = cf.merge(lambda);
95
+ if (update) fixtures.update('lambda-docker', template);
96
+ expect(noUndefined(template)).toEqual(fixtures.get('lambda-docker'));
124
97
  });
125
98
 
126
- template = cf.merge(lambda);
127
- if (update) fixtures.update('lambda-zipfile', template);
128
- assert.deepEqual(
129
- noUndefined(template),
130
- fixtures.get('lambda-zipfile'),
131
- 'expected resources generated using all default values and inline code'
132
- );
99
+ test('expected resources generated using all default values and inline code', () => {
100
+ const lambda = new cf.shortcuts.Lambda({
101
+ LogicalName: 'MyLambda',
102
+ Code: {
103
+ ZipFile: 'fake code'
104
+ }
105
+ });
133
106
 
134
- lambda = new cf.shortcuts.Lambda({
135
- LogicalName: 'MyLambda',
136
- Code: {
137
- S3Bucket: 'my-code-bucket',
138
- S3Key: 'path/to/code.zip'
139
- },
140
- RoleArn: cf.getAtt('CustomLambdaRole', 'Arn')
141
- });
142
-
143
- template = cf.merge(lambda, {
144
- Resources: {
145
- 'CustomLambdaRole': {
146
- Type: 'AWS::IAM::Role',
147
- Properties: {
148
- AssumeRolePolicyDocument: {}
107
+ const template = cf.merge(lambda);
108
+ if (update) fixtures.update('lambda-zipfile', template);
109
+ expect(noUndefined(template)).toEqual(fixtures.get('lambda-zipfile'));
110
+ });
111
+
112
+ test('expected resources generated if RoleArn provided', () => {
113
+ const lambda = new cf.shortcuts.Lambda({
114
+ LogicalName: 'MyLambda',
115
+ Code: {
116
+ S3Bucket: 'my-code-bucket',
117
+ S3Key: 'path/to/code.zip'
118
+ },
119
+ RoleArn: cf.getAtt('CustomLambdaRole', 'Arn')
120
+ });
121
+
122
+ const template = cf.merge(lambda, {
123
+ Resources: {
124
+ 'CustomLambdaRole': {
125
+ Type: 'AWS::IAM::Role',
126
+ Properties: {
127
+ AssumeRolePolicyDocument: {}
128
+ }
149
129
  }
150
130
  }
151
- }
131
+ });
132
+ if (update) fixtures.update('lambda-provided-role', template);
133
+ expect(noUndefined(template)).toEqual(fixtures.get('lambda-provided-role'));
152
134
  });
153
- if (update) fixtures.update('lambda-provided-role', template);
154
- assert.deepEqual(
155
- noUndefined(template),
156
- fixtures.get('lambda-provided-role'),
157
- 'expected resources generated if RoleArn provided'
158
- );
159
135
 
160
- lambda = new cf.shortcuts.Lambda({
161
- LogicalName: 'MyLambda',
162
- Code: {
163
- S3Bucket: 'my-code-bucket',
164
- S3Key: 'path/to/code.zip'
165
- },
166
- DeadLetterConfig: {
167
- TargetArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake'
168
- },
169
- Description: 'my description',
170
- Environment: { Variables: { MyCoolEnv: 'a' } },
171
- FunctionName: 'my-function',
172
- Handler: 'index.something',
173
- KmsKeyArn: 'arn:aws:kms:us-east-1:123456789012:key/fake',
174
- Layers: ['arn:aws:lambda:us-east-2:590474943231:layer:AWS-Parameters-and-Secrets-Lambda-Extension:4'],
175
- MemorySize: 512,
176
- ReservedConcurrentExecutions: 10,
177
- Runtime: 'nodejs22.x',
178
- Tags: [{ Key: 'a', Value: 'b' }],
179
- Timeout: 30,
180
- TracingConfig: { Mode: 'Active' },
181
- VpcConfig: {
182
- SecurityGroupIds: ['sg-12345678'],
183
- SubnetIds: ['fake']
184
- },
185
- Condition: 'Always',
186
- DependsOn: 'AnotherThing',
187
- Statement: [
188
- {
189
- Effect: 'Allow',
190
- Action: 's3:GetObject',
191
- Resource: 'arn:aws:s3:::fake/data'
192
- }
193
- ],
194
- AlarmName: 'my-alarm',
195
- AlarmDescription: 'some alarm',
196
- AlarmActions: ['devnull@mapbox.com'],
197
- Period: 120,
198
- EvaluationPeriods: 2,
199
- Statistic: 'Minimum',
200
- Threshold: 10,
201
- ComparisonOperator: 'LessThanThreshold',
202
- TreatMissingData: 'breaching',
203
- EvaluateLowSampleCountPercentile: 'ignore',
204
- ExtendedStatistics: 'p100',
205
- OKActions: ['devnull@mapbox.com'],
206
- LogRetentionInDays: 30
207
- });
208
-
209
- template = cf.merge(
210
- { Conditions: { Always: cf.equals('1', '1') } },
211
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
212
- lambda
213
- );
214
- if (update) fixtures.update('lambda-full', template);
215
- assert.deepEqual(
216
- noUndefined(template),
217
- fixtures.get('lambda-full'),
218
- 'expected resources generated using no default values'
219
- );
136
+ test('expected resources generated using no default values', () => {
137
+ const lambda = new cf.shortcuts.Lambda({
138
+ LogicalName: 'MyLambda',
139
+ Code: {
140
+ S3Bucket: 'my-code-bucket',
141
+ S3Key: 'path/to/code.zip'
142
+ },
143
+ DeadLetterConfig: {
144
+ TargetArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake'
145
+ },
146
+ Description: 'my description',
147
+ Environment: { Variables: { MyCoolEnv: 'a' } },
148
+ FunctionName: 'my-function',
149
+ Handler: 'index.something',
150
+ KmsKeyArn: 'arn:aws:kms:us-east-1:123456789012:key/fake',
151
+ Layers: ['arn:aws:lambda:us-east-2:590474943231:layer:AWS-Parameters-and-Secrets-Lambda-Extension:4'],
152
+ MemorySize: 512,
153
+ ReservedConcurrentExecutions: 10,
154
+ Runtime: 'nodejs22.x',
155
+ Tags: [{ Key: 'a', Value: 'b' }],
156
+ Timeout: 30,
157
+ TracingConfig: { Mode: 'Active' },
158
+ VpcConfig: {
159
+ SecurityGroupIds: ['sg-12345678'],
160
+ SubnetIds: ['fake']
161
+ },
162
+ Condition: 'Always',
163
+ DependsOn: 'AnotherThing',
164
+ Statement: [
165
+ {
166
+ Effect: 'Allow',
167
+ Action: 's3:GetObject',
168
+ Resource: 'arn:aws:s3:::fake/data'
169
+ }
170
+ ],
171
+ AlarmName: 'my-alarm',
172
+ AlarmDescription: 'some alarm',
173
+ AlarmActions: ['devnull@mapbox.com'],
174
+ Period: 120,
175
+ EvaluationPeriods: 2,
176
+ Statistic: 'Minimum',
177
+ Threshold: 10,
178
+ ComparisonOperator: 'LessThanThreshold',
179
+ TreatMissingData: 'breaching',
180
+ EvaluateLowSampleCountPercentile: 'ignore',
181
+ ExtendedStatistics: 'p100',
182
+ OKActions: ['devnull@mapbox.com'],
183
+ LogRetentionInDays: 30
184
+ });
185
+
186
+ const template = cf.merge(
187
+ { Conditions: { Always: cf.equals('1', '1') } },
188
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
189
+ lambda
190
+ );
191
+ if (update) fixtures.update('lambda-full', template);
192
+ expect(noUndefined(template)).toEqual(fixtures.get('lambda-full'));
193
+ });
194
+
195
+ test('LogPolicyName parameter correctly overrides the default policy name', () => {
196
+ const lambda = new cf.shortcuts.Lambda({
197
+ LogicalName: 'MyLambda',
198
+ Code: {
199
+ S3Bucket: 'my-code-bucket',
200
+ S3Key: 'path/to/code.zip'
201
+ },
202
+ LogPolicyName: 'CustomLogPolicyName'
203
+ });
220
204
 
221
- assert.end();
205
+ const template = cf.merge(lambda);
206
+ expect(template.Resources.MyLambdaLogPolicy.Properties.PolicyName).toBe('CustomLogPolicyName');
207
+ });
222
208
  });
223
209
 
224
- test('[shortcuts] queue-lambda', (assert) => {
225
- assert.throws(
226
- () => new cf.shortcuts.QueueLambda(),
227
- 'Options required',
228
- 'throws without options'
229
- );
230
- assert.throws(
231
- () => new cf.shortcuts.QueueLambda({}),
232
- /You must provide a LogicalName, and Code/,
233
- 'throws without basic lambda required parameters'
234
- );
210
+ describe('[shortcuts] queue-lambda', () => {
211
+ test('throws without options', () => {
212
+ expect(() => new cf.shortcuts.QueueLambda()).toThrow('Options required');
213
+ });
235
214
 
236
- assert.throws(
237
- () =>
238
- new cf.shortcuts.QueueLambda({
239
- LogicalName: 'MyLambda',
240
- Code: {
241
- S3Bucket: 'my-code-bucket',
242
- S3Key: 'path/to/code.zip'
243
- }
244
- }),
245
- /You must provide an EventSourceArn and ReservedConcurrentExecutions/,
246
- 'throws without queue-lambda required parameters'
247
- );
215
+ test('throws without basic lambda required parameters', () => {
216
+ expect(() => new cf.shortcuts.QueueLambda({})).toThrow(/You must provide a LogicalName, and Code/);
217
+ });
248
218
 
249
- assert.throws(
250
- () =>
251
- new cf.shortcuts.QueueLambda({
252
- LogicalName: 'MyLambda',
253
- Code: {
254
- S3Bucket: 'my-code-bucket',
255
- S3Key: 'path/to/code.zip'
256
- },
257
- EventSourceArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake',
258
- ReservedConcurrentExecutions: -1
259
- }),
260
- /ReservedConcurrentExecutions must be greater than or equal to 0/,
261
- 'throws when ReservedConcurrentExecutions is a negative number'
262
- );
219
+ test('throws without queue-lambda required parameters', () => {
220
+ expect(() => new cf.shortcuts.QueueLambda({
221
+ LogicalName: 'MyLambda',
222
+ Code: {
223
+ S3Bucket: 'my-code-bucket',
224
+ S3Key: 'path/to/code.zip'
225
+ }
226
+ })).toThrow(/You must provide an EventSourceArn and ReservedConcurrentExecutions/);
227
+ });
263
228
 
264
- const zeroLambda = new cf.shortcuts.QueueLambda({
265
- LogicalName: 'MyLambda',
266
- Code: {
267
- S3Bucket: 'my-code-bucket',
268
- S3Key: 'path/to/code.zip'
269
- },
270
- EventSourceArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake',
271
- ReservedConcurrentExecutions: 0
272
- });
273
- const zeroTemplate = cf.merge(zeroLambda);
274
- if (update) fixtures.update('queue-lambda-zero', zeroTemplate);
275
- assert.deepEqual(
276
- noUndefined(zeroTemplate),
277
- fixtures.get('queue-lambda-zero'),
278
- 'expected resources generated'
279
- );
229
+ test('throws when ReservedConcurrentExecutions is a negative number', () => {
230
+ expect(() => new cf.shortcuts.QueueLambda({
231
+ LogicalName: 'MyLambda',
232
+ Code: {
233
+ S3Bucket: 'my-code-bucket',
234
+ S3Key: 'path/to/code.zip'
235
+ },
236
+ EventSourceArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake',
237
+ ReservedConcurrentExecutions: -1
238
+ })).toThrow(/ReservedConcurrentExecutions must be greater than or equal to 0/);
239
+ });
280
240
 
281
- const lambda = new cf.shortcuts.QueueLambda({
282
- LogicalName: 'MyLambda',
283
- Code: {
284
- S3Bucket: 'my-code-bucket',
285
- S3Key: 'path/to/code.zip'
286
- },
287
- EventSourceArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake',
288
- ReservedConcurrentExecutions: 10
289
- });
290
-
291
- const template = cf.merge(lambda);
292
- if (update) fixtures.update('queue-lambda', template);
293
- assert.deepEqual(
294
- noUndefined(template),
295
- fixtures.get('queue-lambda'),
296
- 'expected resources generated'
297
- );
241
+ test('expected resources generated with zero concurrency', () => {
242
+ const zeroLambda = new cf.shortcuts.QueueLambda({
243
+ LogicalName: 'MyLambda',
244
+ Code: {
245
+ S3Bucket: 'my-code-bucket',
246
+ S3Key: 'path/to/code.zip'
247
+ },
248
+ EventSourceArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake',
249
+ ReservedConcurrentExecutions: 0
250
+ });
251
+ const zeroTemplate = cf.merge(zeroLambda);
252
+ if (update) fixtures.update('queue-lambda-zero', zeroTemplate);
253
+ expect(noUndefined(zeroTemplate)).toEqual(fixtures.get('queue-lambda-zero'));
254
+ });
255
+
256
+ test('expected resources generated', () => {
257
+ const lambda = new cf.shortcuts.QueueLambda({
258
+ LogicalName: 'MyLambda',
259
+ Code: {
260
+ S3Bucket: 'my-code-bucket',
261
+ S3Key: 'path/to/code.zip'
262
+ },
263
+ EventSourceArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake',
264
+ ReservedConcurrentExecutions: 10
265
+ });
298
266
 
299
- assert.end();
267
+ const template = cf.merge(lambda);
268
+ if (update) fixtures.update('queue-lambda', template);
269
+ expect(noUndefined(template)).toEqual(fixtures.get('queue-lambda'));
270
+ });
300
271
  });
301
272
 
302
- test('[shortcuts] scheduled-lambda', (assert) => {
303
- assert.throws(
304
- () => new cf.shortcuts.ScheduledLambda(),
305
- 'Options required',
306
- 'throws without options'
307
- );
308
- assert.throws(
309
- () => new cf.shortcuts.ScheduledLambda({}),
310
- /You must provide a LogicalName, and Code/,
311
- 'throws without basic lambda required parameters'
312
- );
273
+ describe('[shortcuts] scheduled-lambda', () => {
274
+ test('throws without options', () => {
275
+ expect(() => new cf.shortcuts.ScheduledLambda()).toThrow('Options required');
276
+ });
313
277
 
314
- assert.throws(
315
- () =>
316
- new cf.shortcuts.ScheduledLambda({
317
- LogicalName: 'MyLambda',
318
- Code: {
319
- S3Bucket: 'my-code-bucket',
320
- S3Key: 'path/to/code.zip'
321
- }
322
- }),
323
- /You must provide a ScheduleExpression/,
324
- 'throws without scheduled-lambda required parameters'
325
- );
278
+ test('throws without basic lambda required parameters', () => {
279
+ expect(() => new cf.shortcuts.ScheduledLambda({})).toThrow(/You must provide a LogicalName, and Code/);
280
+ });
326
281
 
327
- let lambda = new cf.shortcuts.ScheduledLambda({
328
- LogicalName: 'MyLambda',
329
- Code: {
330
- S3Bucket: 'my-code-bucket',
331
- S3Key: 'path/to/code.zip'
332
- },
333
- ScheduleExpression: 'rate(1 hour)'
334
- });
335
-
336
- let template = cf.merge(lambda);
337
- if (update) fixtures.update('scheduled-lambda-defaults', template);
338
- assert.deepEqual(
339
- noUndefined(template),
340
- fixtures.get('scheduled-lambda-defaults'),
341
- 'expected resources generated with defaults'
342
- );
282
+ test('throws without scheduled-lambda required parameters', () => {
283
+ expect(() => new cf.shortcuts.ScheduledLambda({
284
+ LogicalName: 'MyLambda',
285
+ Code: {
286
+ S3Bucket: 'my-code-bucket',
287
+ S3Key: 'path/to/code.zip'
288
+ }
289
+ })).toThrow(/You must provide a ScheduleExpression/);
290
+ });
343
291
 
344
- lambda = new cf.shortcuts.ScheduledLambda({
345
- LogicalName: 'MyLambda',
346
- Code: {
347
- S3Bucket: 'my-code-bucket',
348
- S3Key: 'path/to/code.zip'
349
- },
350
- ScheduleRoleArn: 'arn:aws:iam::012345678901:role/MyCoolRole',
351
- ScheduleGroupName: 'my-cool-stack',
352
- ScheduleExpression: 'rate(1 hour)',
353
- State: 'DISABLED'
354
- });
355
-
356
- template = cf.merge(lambda);
357
- if (update) fixtures.update('scheduled-lambda-full', template);
358
- assert.deepEqual(
359
- noUndefined(template),
360
- fixtures.get('scheduled-lambda-full'),
361
- 'expected resources generated without defaults'
362
- );
292
+ test('expected resources generated with defaults', () => {
293
+ const lambda = new cf.shortcuts.ScheduledLambda({
294
+ LogicalName: 'MyLambda',
295
+ Code: {
296
+ S3Bucket: 'my-code-bucket',
297
+ S3Key: 'path/to/code.zip'
298
+ },
299
+ ScheduleExpression: 'rate(1 hour)'
300
+ });
363
301
 
364
- assert.end();
302
+ const template = cf.merge(lambda);
303
+ if (update) fixtures.update('scheduled-lambda-defaults', template);
304
+ expect(noUndefined(template)).toEqual(fixtures.get('scheduled-lambda-defaults'));
305
+ });
306
+
307
+ test('expected resources generated without defaults', () => {
308
+ const lambda = new cf.shortcuts.ScheduledLambda({
309
+ LogicalName: 'MyLambda',
310
+ Code: {
311
+ S3Bucket: 'my-code-bucket',
312
+ S3Key: 'path/to/code.zip'
313
+ },
314
+ ScheduleRoleArn: 'arn:aws:iam::012345678901:role/MyCoolRole',
315
+ ScheduleGroupName: 'my-cool-stack',
316
+ ScheduleExpression: 'rate(1 hour)',
317
+ State: 'DISABLED'
318
+ });
319
+
320
+ const template = cf.merge(lambda);
321
+ if (update) fixtures.update('scheduled-lambda-full', template);
322
+ expect(noUndefined(template)).toEqual(fixtures.get('scheduled-lambda-full'));
323
+ });
365
324
  });
366
325
 
367
- test('[shortcuts] event-lambda', (assert) => {
368
- assert.throws(
369
- () => new cf.shortcuts.EventLambda(),
370
- 'Options required',
371
- 'throws without options'
372
- );
373
- assert.throws(
374
- () => new cf.shortcuts.EventLambda({}),
375
- /You must provide a LogicalName, and Code/,
376
- 'throws without basic lambda required parameters'
377
- );
326
+ describe('[shortcuts] event-lambda', () => {
327
+ test('throws without options', () => {
328
+ expect(() => new cf.shortcuts.EventLambda()).toThrow('Options required');
329
+ });
378
330
 
379
- assert.throws(
380
- () =>
381
- new cf.shortcuts.EventLambda({
382
- LogicalName: 'MyLambda',
383
- Code: {
384
- S3Bucket: 'my-code-bucket',
385
- S3Key: 'path/to/code.zip'
386
- }
387
- }),
388
- /You must provide an EventPattern/,
389
- 'throws without event-lambda required parameters'
390
- );
331
+ test('throws without basic lambda required parameters', () => {
332
+ expect(() => new cf.shortcuts.EventLambda({})).toThrow(/You must provide a LogicalName, and Code/);
333
+ });
391
334
 
392
- let lambda = new cf.shortcuts.EventLambda({
393
- LogicalName: 'MyLambda',
394
- Code: {
395
- S3Bucket: 'my-code-bucket',
396
- S3Key: 'path/to/code.zip'
397
- },
398
- EventPattern: {
399
- source: ['aws.ec2'],
400
- 'detail-type': ['EC2 Instance State-change Notification'],
401
- detail: {
402
- state: ['running']
335
+ test('throws without event-lambda required parameters', () => {
336
+ expect(() => new cf.shortcuts.EventLambda({
337
+ LogicalName: 'MyLambda',
338
+ Code: {
339
+ S3Bucket: 'my-code-bucket',
340
+ S3Key: 'path/to/code.zip'
403
341
  }
404
- }
342
+ })).toThrow(/You must provide an EventPattern/);
405
343
  });
406
344
 
407
- let template = cf.merge(lambda);
408
- if (update) fixtures.update('event-lambda-defaults', template);
409
- assert.deepEqual(
410
- noUndefined(template),
411
- fixtures.get('event-lambda-defaults'),
412
- 'expected resources generated with defaults'
413
- );
414
-
415
- lambda = new cf.shortcuts.EventLambda({
416
- LogicalName: 'MyLambda',
417
- Code: {
418
- S3Bucket: 'my-code-bucket',
419
- S3Key: 'path/to/code.zip'
420
- },
421
- EventPattern: {
422
- source: ['aws.ec2'],
423
- 'detail-type': ['EC2 Instance State-change Notification'],
424
- detail: {
425
- state: ['running']
345
+ test('expected resources generated with defaults', () => {
346
+ const lambda = new cf.shortcuts.EventLambda({
347
+ LogicalName: 'MyLambda',
348
+ Code: {
349
+ S3Bucket: 'my-code-bucket',
350
+ S3Key: 'path/to/code.zip'
351
+ },
352
+ EventPattern: {
353
+ source: ['aws.ec2'],
354
+ 'detail-type': ['EC2 Instance State-change Notification'],
355
+ detail: {
356
+ state: ['running']
357
+ }
426
358
  }
427
- },
428
- State: 'DISABLED'
359
+ });
360
+
361
+ const template = cf.merge(lambda);
362
+ if (update) fixtures.update('event-lambda-defaults', template);
363
+ expect(noUndefined(template)).toEqual(fixtures.get('event-lambda-defaults'));
429
364
  });
430
365
 
431
- template = cf.merge(lambda);
432
- if (update) fixtures.update('event-lambda-full', template);
433
- assert.deepEqual(
434
- noUndefined(template),
435
- fixtures.get('event-lambda-full'),
436
- 'expected resources generated without defaults'
437
- );
366
+ test('expected resources generated without defaults', () => {
367
+ const lambda = new cf.shortcuts.EventLambda({
368
+ LogicalName: 'MyLambda',
369
+ Code: {
370
+ S3Bucket: 'my-code-bucket',
371
+ S3Key: 'path/to/code.zip'
372
+ },
373
+ EventPattern: {
374
+ source: ['aws.ec2'],
375
+ 'detail-type': ['EC2 Instance State-change Notification'],
376
+ detail: {
377
+ state: ['running']
378
+ }
379
+ },
380
+ State: 'DISABLED'
381
+ });
438
382
 
439
- assert.end();
383
+ const template = cf.merge(lambda);
384
+ if (update) fixtures.update('event-lambda-full', template);
385
+ expect(noUndefined(template)).toEqual(fixtures.get('event-lambda-full'));
386
+ });
440
387
  });
441
388
 
442
- test('[shortcuts] stream-lambda', (assert) => {
443
- assert.throws(
444
- () => new cf.shortcuts.StreamLambda(),
445
- 'Options required',
446
- 'throws without options'
447
- );
448
- assert.throws(
449
- () => new cf.shortcuts.StreamLambda({}),
450
- /You must provide a LogicalName, and Code/,
451
- 'throws without basic lambda required parameters'
452
- );
389
+ describe('[shortcuts] stream-lambda', () => {
390
+ test('throws without options', () => {
391
+ expect(() => new cf.shortcuts.StreamLambda()).toThrow('Options required');
392
+ });
453
393
 
454
- assert.throws(
455
- () =>
456
- new cf.shortcuts.StreamLambda({
457
- LogicalName: 'MyLambda',
458
- Code: {
459
- S3Bucket: 'my-code-bucket',
460
- S3Key: 'path/to/code.zip'
461
- }
462
- }),
463
- /You must provide an EventSourceArn/,
464
- 'throws without stream-lambda required parameters'
465
- );
394
+ test('throws without basic lambda required parameters', () => {
395
+ expect(() => new cf.shortcuts.StreamLambda({})).toThrow(/You must provide a LogicalName, and Code/);
396
+ });
466
397
 
467
- let lambda = new cf.shortcuts.StreamLambda({
468
- LogicalName: 'MyLambda',
469
- Code: {
470
- S3Bucket: 'my-code-bucket',
471
- S3Key: 'path/to/code.zip'
472
- },
473
- EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake'
474
- });
475
-
476
- let template = cf.merge(lambda);
477
- if (update) fixtures.update('stream-lambda-defaults', template);
478
- assert.deepEqual(
479
- noUndefined(template),
480
- fixtures.get('stream-lambda-defaults'),
481
- 'expected resources generated via defaults'
482
- );
398
+ test('throws without stream-lambda required parameters', () => {
399
+ expect(() => new cf.shortcuts.StreamLambda({
400
+ LogicalName: 'MyLambda',
401
+ Code: {
402
+ S3Bucket: 'my-code-bucket',
403
+ S3Key: 'path/to/code.zip'
404
+ }
405
+ })).toThrow(/You must provide an EventSourceArn/);
406
+ });
483
407
 
484
- lambda = new cf.shortcuts.StreamLambda({
485
- LogicalName: 'MyLambda',
486
- Code: {
487
- S3Bucket: 'my-code-bucket',
488
- S3Key: 'path/to/code.zip'
489
- },
490
- EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake',
491
- FilterCriteria: {
492
- Filters: [
493
- {
494
- Pattern: JSON.stringify({ eventName: ['INSERT', 'MODIFY'] })
495
- }
496
- ]
497
- },
498
- BatchSize: 10000,
499
- MaximumBatchingWindowInSeconds: 300,
500
- Enabled: false,
501
- StartingPosition: 'TRIM_HORIZON'
502
- });
503
-
504
- template = cf.merge(lambda);
505
- if (update) fixtures.update('stream-lambda-no-defaults', template);
506
- assert.deepEqual(
507
- noUndefined(template),
508
- fixtures.get('stream-lambda-no-defaults'),
509
- 'expected resources generated without defaults'
510
- );
408
+ test('expected resources generated via defaults', () => {
409
+ const lambda = new cf.shortcuts.StreamLambda({
410
+ LogicalName: 'MyLambda',
411
+ Code: {
412
+ S3Bucket: 'my-code-bucket',
413
+ S3Key: 'path/to/code.zip'
414
+ },
415
+ EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake'
416
+ });
417
+
418
+ const template = cf.merge(lambda);
419
+ if (update) fixtures.update('stream-lambda-defaults', template);
420
+ expect(noUndefined(template)).toEqual(fixtures.get('stream-lambda-defaults'));
421
+ });
511
422
 
512
- assert.end();
423
+ test('expected resources generated without defaults', () => {
424
+ const lambda = new cf.shortcuts.StreamLambda({
425
+ LogicalName: 'MyLambda',
426
+ Code: {
427
+ S3Bucket: 'my-code-bucket',
428
+ S3Key: 'path/to/code.zip'
429
+ },
430
+ EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake',
431
+ FilterCriteria: {
432
+ Filters: [
433
+ {
434
+ Pattern: JSON.stringify({ eventName: ['INSERT', 'MODIFY'] })
435
+ }
436
+ ]
437
+ },
438
+ BatchSize: 10000,
439
+ MaximumBatchingWindowInSeconds: 300,
440
+ Enabled: false,
441
+ StartingPosition: 'TRIM_HORIZON'
442
+ });
443
+
444
+ const template = cf.merge(lambda);
445
+ if (update) fixtures.update('stream-lambda-no-defaults', template);
446
+ expect(noUndefined(template)).toEqual(fixtures.get('stream-lambda-no-defaults'));
447
+ });
513
448
  });
514
449
 
515
- test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
516
- assert.throws(
517
- () => new cf.shortcuts.StreamLambda({
450
+ describe('[shortcuts] StreamLambda FilterCriteria', () => {
451
+ test('FilterCriteria must be a JSON-like object', () => {
452
+ expect(() => new cf.shortcuts.StreamLambda({
518
453
  LogicalName: 'MyLambda',
519
454
  Code: {
520
455
  S3Bucket: 'my-code-bucket',
@@ -522,11 +457,11 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
522
457
  },
523
458
  EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake',
524
459
  FilterCriteria: ['test']
525
- }),
526
- '`FilterCriteria` must be a JSON-like object',
527
- );
528
- assert.throws(
529
- () => new cf.shortcuts.StreamLambda({
460
+ })).toThrow();
461
+ });
462
+
463
+ test('FilterCriteria must contain property Filter of type array', () => {
464
+ expect(() => new cf.shortcuts.StreamLambda({
530
465
  LogicalName: 'MyLambda',
531
466
  Code: {
532
467
  S3Bucket: 'my-code-bucket',
@@ -534,11 +469,11 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
534
469
  },
535
470
  EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake',
536
471
  FilterCriteria: {}
537
- }),
538
- '`FilterCriteria` must contain property `Filter` of type array',
539
- );
540
- assert.throws(
541
- () => new cf.shortcuts.StreamLambda({
472
+ })).toThrow();
473
+ });
474
+
475
+ test('FilterCriteria.Filter must be an array', () => {
476
+ expect(() => new cf.shortcuts.StreamLambda({
542
477
  LogicalName: 'MyLambda',
543
478
  Code: {
544
479
  S3Bucket: 'my-code-bucket',
@@ -548,11 +483,11 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
548
483
  FilterCriteria: {
549
484
  Filter: 613
550
485
  }
551
- }),
552
- '`FilterCriteria` must contain property `Filter` of type array',
553
- );
554
- assert.throws(
555
- () => new cf.shortcuts.StreamLambda({
486
+ })).toThrow();
487
+ });
488
+
489
+ test('FilterCriteria.Filter objects must have Pattern property', () => {
490
+ expect(() => new cf.shortcuts.StreamLambda({
556
491
  LogicalName: 'MyLambda',
557
492
  Code: {
558
493
  S3Bucket: 'my-code-bucket',
@@ -569,11 +504,11 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
569
504
  }
570
505
  ]
571
506
  }
572
- }),
573
- 'An object in `FilterCriteria.Filter` was missing the required property `Pattern`',
574
- );
575
- assert.throws(
576
- () => new cf.shortcuts.StreamLambda({
507
+ })).toThrow();
508
+ });
509
+
510
+ test('FilterCriteria.Filter Pattern must be JSON parseable string', () => {
511
+ expect(() => new cf.shortcuts.StreamLambda({
577
512
  LogicalName: 'MyLambda',
578
513
  Code: {
579
514
  S3Bucket: 'my-code-bucket',
@@ -590,930 +525,798 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
590
525
  }
591
526
  ]
592
527
  }
593
- }),
594
- 'An object in `FilterCriteria.Filter` contains a `Pattern` property that is not a JSON parseable string',
595
- );
596
- assert.end();
528
+ })).toThrow();
529
+ });
597
530
  });
598
531
 
599
- test('[shortcuts] log-subscription-lambda', (assert) => {
600
- assert.throws(
601
- () => new cf.shortcuts.LogSubscriptionLambda(),
602
- 'Options required',
603
- 'throws without options'
604
- );
605
- assert.throws(
606
- () => new cf.shortcuts.LogSubscriptionLambda({}),
607
- /You must provide a LogicalName, and Code/,
608
- 'throws without basic lambda required parameters'
609
- );
532
+ describe('[shortcuts] log-subscription-lambda', () => {
533
+ test('throws without options', () => {
534
+ expect(() => new cf.shortcuts.LogSubscriptionLambda()).toThrow('Options required');
535
+ });
610
536
 
611
- assert.throws(
612
- () =>
613
- new cf.shortcuts.LogSubscriptionLambda({
614
- LogicalName: 'MyLambda',
615
- Code: {
616
- S3Bucket: 'my-code-bucket',
617
- S3Key: 'path/to/code.zip'
618
- }
619
- }),
620
- /You must provide a LogGroupName/,
621
- 'throws without log-subscription-lambda required parameters'
622
- );
537
+ test('throws without basic lambda required parameters', () => {
538
+ expect(() => new cf.shortcuts.LogSubscriptionLambda({})).toThrow(/You must provide a LogicalName, and Code/);
539
+ });
623
540
 
624
- let lambda = new cf.shortcuts.LogSubscriptionLambda({
625
- LogicalName: 'MyLambda',
626
- Code: {
627
- S3Bucket: 'my-code-bucket',
628
- S3Key: 'path/to/code.zip'
629
- },
630
- LogGroupName: 'my-log-group'
631
- });
632
-
633
- let template = cf.merge(lambda);
634
- if (update) fixtures.update('log-subscription-lambda-defaults', template);
635
- assert.deepEqual(
636
- noUndefined(template),
637
- fixtures.get('log-subscription-lambda-defaults'),
638
- 'expected resources generated via defaults'
639
- );
541
+ test('throws without log-subscription-lambda required parameters', () => {
542
+ expect(() => new cf.shortcuts.LogSubscriptionLambda({
543
+ LogicalName: 'MyLambda',
544
+ Code: {
545
+ S3Bucket: 'my-code-bucket',
546
+ S3Key: 'path/to/code.zip'
547
+ }
548
+ })).toThrow(/You must provide a LogGroupName/);
549
+ });
640
550
 
641
- lambda = new cf.shortcuts.LogSubscriptionLambda({
642
- LogicalName: 'MyLambda',
643
- Code: {
644
- S3Bucket: 'my-code-bucket',
645
- S3Key: 'path/to/code.zip'
646
- },
647
- FilterPattern: '{ $.errorCode = 400 }',
648
- LogGroupName: 'my-log-group'
649
- });
650
-
651
- template = cf.merge(lambda);
652
- if (update) fixtures.update('log-subscription-lambda-no-defaults', template);
653
- assert.deepEqual(
654
- noUndefined(template),
655
- fixtures.get('log-subscription-lambda-no-defaults'),
656
- 'expected resources generated without defaults'
657
- );
551
+ test('expected resources generated via defaults', () => {
552
+ const lambda = new cf.shortcuts.LogSubscriptionLambda({
553
+ LogicalName: 'MyLambda',
554
+ Code: {
555
+ S3Bucket: 'my-code-bucket',
556
+ S3Key: 'path/to/code.zip'
557
+ },
558
+ LogGroupName: 'my-log-group'
559
+ });
658
560
 
659
- assert.end();
561
+ const template = cf.merge(lambda);
562
+ if (update) fixtures.update('log-subscription-lambda-defaults', template);
563
+ expect(noUndefined(template)).toEqual(fixtures.get('log-subscription-lambda-defaults'));
564
+ });
565
+
566
+ test('expected resources generated without defaults', () => {
567
+ const lambda = new cf.shortcuts.LogSubscriptionLambda({
568
+ LogicalName: 'MyLambda',
569
+ Code: {
570
+ S3Bucket: 'my-code-bucket',
571
+ S3Key: 'path/to/code.zip'
572
+ },
573
+ FilterPattern: '{ $.errorCode = 400 }',
574
+ LogGroupName: 'my-log-group'
575
+ });
576
+
577
+ const template = cf.merge(lambda);
578
+ if (update) fixtures.update('log-subscription-lambda-no-defaults', template);
579
+ expect(noUndefined(template)).toEqual(fixtures.get('log-subscription-lambda-no-defaults'));
580
+ });
660
581
  });
661
582
 
662
- test('[shortcuts] queue', (assert) => {
663
- assert.throws(
664
- () => new cf.shortcuts.Queue(),
665
- 'Options required',
666
- 'throws without options'
667
- );
668
- assert.throws(
669
- () => new cf.shortcuts.Queue({}),
670
- /You must provide a LogicalName/,
671
- 'throws without required parameters'
672
- );
583
+ describe('[shortcuts] queue', () => {
584
+ test('throws without options', () => {
585
+ expect(() => new cf.shortcuts.Queue()).toThrow('Options required');
586
+ });
673
587
 
674
- let queue = new cf.shortcuts.Queue({
675
- LogicalName: 'MyQueue'
588
+ test('throws without required parameters', () => {
589
+ expect(() => new cf.shortcuts.Queue({})).toThrow(/You must provide a LogicalName/);
676
590
  });
677
591
 
678
- let template = cf.merge(queue);
679
- if (update) fixtures.update('queue-defaults', template);
680
- assert.deepEqual(
681
- noUndefined(template),
682
- fixtures.get('queue-defaults'),
683
- 'expected resources generated for full defaults'
684
- );
592
+ test('expected resources generated for full defaults', () => {
593
+ const queue = new cf.shortcuts.Queue({
594
+ LogicalName: 'MyQueue'
595
+ });
685
596
 
686
- queue = new cf.shortcuts.Queue({
687
- LogicalName: 'MyQueue',
688
- VisibilityTimeout: 60,
689
- maxReceiveCount: 100,
690
- DelaySeconds: 60,
691
- KmsMasterKeyId: 'alias/my-key',
692
- KmsDataKeyReusePeriondSeconds: 86400,
693
- MaximumMessageSize: 1024,
694
- MessageRetentionPeriod: 60,
695
- QueueName: 'my-queue',
696
- ReceiveMessageWaitTimeSeconds: 20,
697
- Condition: 'Always',
698
- DependsOn: 'AnotherThing',
699
- TopicName: 'my-topic',
700
- DisplayName: 'topic-display-name',
701
- DeadLetterVisibilityTimeout: 60
702
- });
703
-
704
- template = cf.merge(
705
- { Conditions: { Always: cf.equals('1', '1') } },
706
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
707
- queue
708
- );
709
- if (update) fixtures.update('queue-full', template);
710
- assert.deepEqual(
711
- noUndefined(template),
712
- fixtures.get('queue-full'),
713
- 'expected resources generated no defaults'
714
- );
597
+ const template = cf.merge(queue);
598
+ if (update) fixtures.update('queue-defaults', template);
599
+ expect(noUndefined(template)).toEqual(fixtures.get('queue-defaults'));
600
+ });
715
601
 
716
- queue = new cf.shortcuts.Queue({
717
- LogicalName: 'MyQueue',
718
- ExistingTopicArn: 'arn:aws:sns:us-east-1:111122223333:MyTopic'
602
+ test('expected resources generated no defaults', () => {
603
+ const queue = new cf.shortcuts.Queue({
604
+ LogicalName: 'MyQueue',
605
+ VisibilityTimeout: 60,
606
+ maxReceiveCount: 100,
607
+ DelaySeconds: 60,
608
+ KmsMasterKeyId: 'alias/my-key',
609
+ KmsDataKeyReusePeriondSeconds: 86400,
610
+ MaximumMessageSize: 1024,
611
+ MessageRetentionPeriod: 60,
612
+ QueueName: 'my-queue',
613
+ ReceiveMessageWaitTimeSeconds: 20,
614
+ Condition: 'Always',
615
+ DependsOn: 'AnotherThing',
616
+ TopicName: 'my-topic',
617
+ DisplayName: 'topic-display-name',
618
+ DeadLetterVisibilityTimeout: 60
619
+ });
620
+
621
+ const template = cf.merge(
622
+ { Conditions: { Always: cf.equals('1', '1') } },
623
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
624
+ queue
625
+ );
626
+ if (update) fixtures.update('queue-full', template);
627
+ expect(noUndefined(template)).toEqual(fixtures.get('queue-full'));
719
628
  });
720
- template = cf.merge(queue);
721
- if (update) fixtures.update('queue-external-topic', template);
722
- assert.deepEqual(
723
- noUndefined(template),
724
- fixtures.get('queue-external-topic'),
725
- 'expected resources generated for external topic'
726
- );
727
629
 
728
- queue = new cf.shortcuts.Queue({
729
- LogicalName: 'MyQueue',
730
- ExistingTopicArn: { Ref: 'TopicForOtherThing' }
630
+ test('expected resources generated for external topic', () => {
631
+ const queue = new cf.shortcuts.Queue({
632
+ LogicalName: 'MyQueue',
633
+ ExistingTopicArn: 'arn:aws:sns:us-east-1:111122223333:MyTopic'
634
+ });
635
+ const template = cf.merge(queue);
636
+ if (update) fixtures.update('queue-external-topic', template);
637
+ expect(noUndefined(template)).toEqual(fixtures.get('queue-external-topic'));
731
638
  });
732
- template = cf.merge(
733
- { Resources: { TopicForOtherThing: { Type: 'AWS::SNS::Topic' } } },
734
- queue
735
- );
736
- if (update) fixtures.update('queue-external-topic-ref', template);
737
- assert.deepEqual(
738
- noUndefined(template),
739
- fixtures.get('queue-external-topic-ref'),
740
- 'expected resources generated for external topic identified by ref'
741
- );
742
639
 
743
- queue = new cf.shortcuts.Queue({
744
- LogicalName: 'MyFifoQueue',
745
- FifoQueue: true
640
+ test('expected resources generated for external topic identified by ref', () => {
641
+ const queue = new cf.shortcuts.Queue({
642
+ LogicalName: 'MyQueue',
643
+ ExistingTopicArn: { Ref: 'TopicForOtherThing' }
644
+ });
645
+ const template = cf.merge(
646
+ { Resources: { TopicForOtherThing: { Type: 'AWS::SNS::Topic' } } },
647
+ queue
648
+ );
649
+ if (update) fixtures.update('queue-external-topic-ref', template);
650
+ expect(noUndefined(template)).toEqual(fixtures.get('queue-external-topic-ref'));
746
651
  });
747
- template = cf.merge(queue);
748
- if (update) fixtures.update('queue-fifo', template);
749
- assert.deepEqual(
750
- noUndefined(template),
751
- fixtures.get('queue-fifo'),
752
- 'expected resources generated for FIFO queue'
753
- );
754
652
 
755
- queue = new cf.shortcuts.Queue({
756
- LogicalName: 'MyFifoQueue',
757
- QueueName: 'custom-and-fancy',
758
- FifoQueue: true
759
- });
760
- template = cf.merge(queue);
761
- if (update) fixtures.update('queue-fifo-queuename', template);
762
- assert.deepEqual(
763
- noUndefined(template),
764
- fixtures.get('queue-fifo-queuename'),
765
- 'expected resources generated for FIFO queue with specified QueueName'
766
- );
653
+ test('expected resources generated for FIFO queue', () => {
654
+ const queue = new cf.shortcuts.Queue({
655
+ LogicalName: 'MyFifoQueue',
656
+ FifoQueue: true
657
+ });
658
+ const template = cf.merge(queue);
659
+ if (update) fixtures.update('queue-fifo', template);
660
+ expect(noUndefined(template)).toEqual(fixtures.get('queue-fifo'));
661
+ });
767
662
 
768
- queue = new cf.shortcuts.Queue({
769
- LogicalName: 'MyFifoFalseQueue',
770
- FifoQueue: false
663
+ test('expected resources generated for FIFO queue with specified QueueName', () => {
664
+ const queue = new cf.shortcuts.Queue({
665
+ LogicalName: 'MyFifoQueue',
666
+ QueueName: 'custom-and-fancy',
667
+ FifoQueue: true
668
+ });
669
+ const template = cf.merge(queue);
670
+ if (update) fixtures.update('queue-fifo-queuename', template);
671
+ expect(noUndefined(template)).toEqual(fixtures.get('queue-fifo-queuename'));
771
672
  });
772
- template = cf.merge(queue);
773
- assert.equal(
774
- template.Resources.MyFifoFalseQueue.Properties.FifoQueue,
775
- undefined,
776
- 'the FifoQueue value false is converted to undefined, to pass CFN validation'
777
- );
778
673
 
779
- assert.end();
674
+ test('the FifoQueue value false is converted to undefined, to pass CFN validation', () => {
675
+ const queue = new cf.shortcuts.Queue({
676
+ LogicalName: 'MyFifoFalseQueue',
677
+ FifoQueue: false
678
+ });
679
+ const template = cf.merge(queue);
680
+ expect(template.Resources.MyFifoFalseQueue.Properties.FifoQueue).toBeUndefined();
681
+ });
780
682
  });
781
683
 
782
- test('[shortcuts] s3 kinesis firehose', (assert) => {
783
- assert.throws(
784
- () => new cf.shortcuts.S3KinesisFirehose(),
785
- 'Options required',
786
- 'throws without options'
787
- );
788
- assert.throws(
789
- () => new cf.shortcuts.S3KinesisFirehose({}),
790
- /You must provide a LogicalName/,
791
- 'throws without required LogicalName parameter'
792
- );
684
+ describe('[shortcuts] s3 kinesis firehose', () => {
685
+ test('throws without options', () => {
686
+ expect(() => new cf.shortcuts.S3KinesisFirehose()).toThrow('Options required');
687
+ });
793
688
 
794
- assert.throws(
795
- () => new cf.shortcuts.S3KinesisFirehose({
796
- LogicalName: 'MyKinesisFirehose'
797
- }),
798
- /You must provide a DestinationBucket/,
799
- 'throws without required DestinationBucket parameter'
800
- );
689
+ test('throws without required LogicalName parameter', () => {
690
+ expect(() => new cf.shortcuts.S3KinesisFirehose({})).toThrow(/You must provide a LogicalName/);
691
+ });
801
692
 
802
- let firehose = new cf.shortcuts.S3KinesisFirehose({
803
- LogicalName: 'MyKinesisFirehose',
804
- DestinationBucket: 'mah-bukkit'
693
+ test('throws without required DestinationBucket parameter', () => {
694
+ expect(() => new cf.shortcuts.S3KinesisFirehose({
695
+ LogicalName: 'MyKinesisFirehose'
696
+ })).toThrow(/You must provide a DestinationBucket/);
805
697
  });
806
698
 
807
- let template = cf.merge(firehose);
808
- if (update) fixtures.update('firehose-defaults', template);
809
- assert.deepEqual(
810
- noUndefined(template),
811
- fixtures.get('firehose-defaults'),
812
- 'expected resources generated for full defaults'
813
- );
699
+ test('expected resources generated for full defaults', () => {
700
+ const firehose = new cf.shortcuts.S3KinesisFirehose({
701
+ LogicalName: 'MyKinesisFirehose',
702
+ DestinationBucket: 'mah-bukkit'
703
+ });
814
704
 
815
- firehose = new cf.shortcuts.S3KinesisFirehose({
816
- LogicalName: 'MyKinesisFirehose',
817
- DestinationBucket: 'mah-bukkit',
818
- KinesisStreamARN: 'arn:aws:kinesis:us-east-1:111122223333:stream/my-stream'
705
+ const template = cf.merge(firehose);
706
+ if (update) fixtures.update('firehose-defaults', template);
707
+ expect(noUndefined(template)).toEqual(fixtures.get('firehose-defaults'));
819
708
  });
820
709
 
821
- template = cf.merge(
822
- { Conditions: { Always: cf.equals('1', '1') } },
823
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
824
- firehose
825
- );
826
- if (update) fixtures.update('firehose-with-stream', template);
827
- assert.deepEqual(
828
- noUndefined(template),
829
- fixtures.get('firehose-with-stream'),
830
- 'expected resources generated with stream'
831
- );
710
+ test('expected resources generated with stream', () => {
711
+ const firehose = new cf.shortcuts.S3KinesisFirehose({
712
+ LogicalName: 'MyKinesisFirehose',
713
+ DestinationBucket: 'mah-bukkit',
714
+ KinesisStreamARN: 'arn:aws:kinesis:us-east-1:111122223333:stream/my-stream'
715
+ });
832
716
 
833
- assert.end();
717
+ const template = cf.merge(
718
+ { Conditions: { Always: cf.equals('1', '1') } },
719
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
720
+ firehose
721
+ );
722
+ if (update) fixtures.update('firehose-with-stream', template);
723
+ expect(noUndefined(template)).toEqual(fixtures.get('firehose-with-stream'));
724
+ });
834
725
  });
835
726
 
836
- test('[shortcuts] role', (assert) => {
837
- assert.throws(
838
- () => new cf.shortcuts.Role(),
839
- 'Options required',
840
- 'throws without options'
841
- );
842
- assert.throws(
843
- () => new cf.shortcuts.Role({}),
844
- /You must provide a LogicalName and AssumeRolePrincipals/,
845
- 'throws without required parameters'
846
- );
727
+ describe('[shortcuts] role', () => {
728
+ test('throws without options', () => {
729
+ expect(() => new cf.shortcuts.Role()).toThrow('Options required');
730
+ });
847
731
 
848
- let role = new cf.shortcuts.Role({
849
- LogicalName: 'MyRole',
850
- AssumeRolePrincipals: [{ Service: 'ec2.amazonaws.com' }]
732
+ test('throws without required parameters', () => {
733
+ expect(() => new cf.shortcuts.Role({})).toThrow(/You must provide a LogicalName and AssumeRolePrincipals/);
851
734
  });
852
735
 
853
- let template = cf.merge(role);
854
- if (update) fixtures.update('role-defaults', template);
855
- assert.deepEqual(
856
- noUndefined(template),
857
- fixtures.get('role-defaults'),
858
- 'expected resources generated with defaults'
859
- );
736
+ test('expected resources generated with defaults', () => {
737
+ const role = new cf.shortcuts.Role({
738
+ LogicalName: 'MyRole',
739
+ AssumeRolePrincipals: [{ Service: 'ec2.amazonaws.com' }]
740
+ });
860
741
 
861
- role = new cf.shortcuts.Role({
862
- LogicalName: 'MyRole',
863
- AssumeRolePrincipals: [{ Service: 'ec2.amazonaws.com' }],
864
- Statement: [
865
- {
866
- Effect: 'Allow',
867
- Action: 's3:GetObject',
868
- Resource: 'arn:aws:s3:::fake/data'
869
- }
870
- ],
871
- ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
872
- MaxSessionDuration: 3600,
873
- Path: '/fake/',
874
- RoleName: 'my-role',
875
- Tags: [{ Key: 'pipeline-name', Value: 'test' }],
876
- Condition: 'Always',
877
- DependsOn: 'AnotherThing'
878
- });
879
-
880
- template = cf.merge(
881
- { Conditions: { Always: cf.equals('1', '1') } },
882
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
883
- role
884
- );
885
- if (update) fixtures.update('role-no-defaults', template);
886
- assert.deepEqual(
887
- noUndefined(template),
888
- fixtures.get('role-no-defaults'),
889
- 'expected resources generated without defaults'
890
- );
742
+ const template = cf.merge(role);
743
+ if (update) fixtures.update('role-defaults', template);
744
+ expect(noUndefined(template)).toEqual(fixtures.get('role-defaults'));
745
+ });
891
746
 
892
- assert.end();
747
+ test('expected resources generated without defaults', () => {
748
+ const role = new cf.shortcuts.Role({
749
+ LogicalName: 'MyRole',
750
+ AssumeRolePrincipals: [{ Service: 'ec2.amazonaws.com' }],
751
+ Statement: [
752
+ {
753
+ Effect: 'Allow',
754
+ Action: 's3:GetObject',
755
+ Resource: 'arn:aws:s3:::fake/data'
756
+ }
757
+ ],
758
+ ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
759
+ MaxSessionDuration: 3600,
760
+ Path: '/fake/',
761
+ RoleName: 'my-role',
762
+ Tags: [{ Key: 'pipeline-name', Value: 'test' }],
763
+ Condition: 'Always',
764
+ DependsOn: 'AnotherThing'
765
+ });
766
+
767
+ const template = cf.merge(
768
+ { Conditions: { Always: cf.equals('1', '1') } },
769
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
770
+ role
771
+ );
772
+ if (update) fixtures.update('role-no-defaults', template);
773
+ expect(noUndefined(template)).toEqual(fixtures.get('role-no-defaults'));
774
+ });
893
775
  });
894
776
 
895
- test('[shortcuts] cross-account role', (assert) => {
896
- assert.throws(
897
- () => new cf.shortcuts.CrossAccountRole(),
898
- 'Options required',
899
- 'throws without options'
900
- );
901
- assert.throws(
902
- () => new cf.shortcuts.CrossAccountRole({}),
903
- /You must provide a LogicalName and Accounts/,
904
- 'throws without required parameters'
905
- );
777
+ describe('[shortcuts] cross-account role', () => {
778
+ test('throws without options', () => {
779
+ expect(() => new cf.shortcuts.CrossAccountRole()).toThrow('Options required');
780
+ });
906
781
 
907
- let role = new cf.shortcuts.CrossAccountRole({
908
- LogicalName: 'MyRole',
909
- Accounts: [
910
- '123456789012',
911
- 'arn:aws:iam::123456789012:root',
912
- { 'Fn::Sub': 'arn:aws:iam::${AWS::AccountId}:root' }
913
- ]
914
- });
915
-
916
- let template = cf.merge(role);
917
- if (update) fixtures.update('cross-account-role-defaults', template);
918
- assert.deepEqual(
919
- noUndefined(template),
920
- fixtures.get('cross-account-role-defaults'),
921
- 'expected resources generated with defaults'
922
- );
782
+ test('throws without required parameters', () => {
783
+ expect(() => new cf.shortcuts.CrossAccountRole({})).toThrow(/You must provide a LogicalName and Accounts/);
784
+ });
923
785
 
924
- role = new cf.shortcuts.CrossAccountRole({
925
- LogicalName: 'MyRole',
926
- Accounts: [
927
- '123456789012',
928
- 'arn:aws:iam::123456789012:root',
929
- { 'Fn::Sub': 'arn:aws:iam::${AWS::AccountId}:root' }
930
- ],
931
- Statement: [
932
- {
933
- Effect: 'Allow',
934
- Action: 's3:GetObject',
935
- Resource: 'arn:aws:s3:::fake/data'
936
- }
937
- ],
938
- ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
939
- MaxSessionDuration: 3600,
940
- Path: '/fake/',
941
- RoleName: 'my-role',
942
- Condition: 'Always',
943
- DependsOn: 'AnotherThing'
944
- });
945
-
946
- template = cf.merge(
947
- { Conditions: { Always: cf.equals('1', '1') } },
948
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
949
- role
950
- );
951
- if (update) fixtures.update('cross-account-role-no-defaults', template);
952
- assert.deepEqual(
953
- noUndefined(template),
954
- fixtures.get('cross-account-role-no-defaults'),
955
- 'expected resources generated without defaults'
956
- );
786
+ test('expected resources generated with defaults', () => {
787
+ const role = new cf.shortcuts.CrossAccountRole({
788
+ LogicalName: 'MyRole',
789
+ Accounts: [
790
+ '123456789012',
791
+ 'arn:aws:iam::123456789012:root',
792
+ { 'Fn::Sub': 'arn:aws:iam::${AWS::AccountId}:root' }
793
+ ]
794
+ });
795
+
796
+ const template = cf.merge(role);
797
+ if (update) fixtures.update('cross-account-role-defaults', template);
798
+ expect(noUndefined(template)).toEqual(fixtures.get('cross-account-role-defaults'));
799
+ });
800
+
801
+ test('expected resources generated without defaults', () => {
802
+ const role = new cf.shortcuts.CrossAccountRole({
803
+ LogicalName: 'MyRole',
804
+ Accounts: [
805
+ '123456789012',
806
+ 'arn:aws:iam::123456789012:root',
807
+ { 'Fn::Sub': 'arn:aws:iam::${AWS::AccountId}:root' }
808
+ ],
809
+ Statement: [
810
+ {
811
+ Effect: 'Allow',
812
+ Action: 's3:GetObject',
813
+ Resource: 'arn:aws:s3:::fake/data'
814
+ }
815
+ ],
816
+ ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
817
+ MaxSessionDuration: 3600,
818
+ Path: '/fake/',
819
+ RoleName: 'my-role',
820
+ Condition: 'Always',
821
+ DependsOn: 'AnotherThing'
822
+ });
957
823
 
958
- assert.end();
824
+ const template = cf.merge(
825
+ { Conditions: { Always: cf.equals('1', '1') } },
826
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
827
+ role
828
+ );
829
+ if (update) fixtures.update('cross-account-role-no-defaults', template);
830
+ expect(noUndefined(template)).toEqual(fixtures.get('cross-account-role-no-defaults'));
831
+ });
959
832
  });
960
833
 
961
- test('[shortcuts] service role', (assert) => {
962
- assert.throws(
963
- () => new cf.shortcuts.ServiceRole(),
964
- 'Options required',
965
- 'throws without options'
966
- );
967
- assert.throws(
968
- () => new cf.shortcuts.ServiceRole({}),
969
- /You must provide a LogicalName and Service/,
970
- 'throws without required parameters'
971
- );
834
+ describe('[shortcuts] service role', () => {
835
+ test('throws without options', () => {
836
+ expect(() => new cf.shortcuts.ServiceRole()).toThrow('Options required');
837
+ });
972
838
 
973
- let role = new cf.shortcuts.ServiceRole({
974
- LogicalName: 'MyRole',
975
- Service: 'lambda'
839
+ test('throws without required parameters', () => {
840
+ expect(() => new cf.shortcuts.ServiceRole({})).toThrow(/You must provide a LogicalName and Service/);
976
841
  });
977
842
 
978
- let template = cf.merge(role);
979
- if (update) fixtures.update('service-role-defaults', template);
980
- assert.deepEqual(
981
- noUndefined(template),
982
- fixtures.get('service-role-defaults'),
983
- 'expected resources generated with defaults'
984
- );
843
+ test('expected resources generated with defaults', () => {
844
+ const role = new cf.shortcuts.ServiceRole({
845
+ LogicalName: 'MyRole',
846
+ Service: 'lambda'
847
+ });
985
848
 
986
- role = new cf.shortcuts.ServiceRole({
987
- LogicalName: 'MyRole',
988
- Service: 'lambda.amazonaws.com'
849
+ const template = cf.merge(role);
850
+ if (update) fixtures.update('service-role-defaults', template);
851
+ expect(noUndefined(template)).toEqual(fixtures.get('service-role-defaults'));
989
852
  });
990
853
 
991
- template = cf.merge(role);
992
- if (update) fixtures.update('service-role-no-url-suffix', template);
993
- assert.deepEqual(
994
- noUndefined(template),
995
- fixtures.get('service-role-no-url-suffix'),
996
- 'expected resources generated, service for which AWS::URLSuffix is invalid'
997
- );
854
+ test('expected resources generated, service for which AWS::URLSuffix is invalid', () => {
855
+ const role = new cf.shortcuts.ServiceRole({
856
+ LogicalName: 'MyRole',
857
+ Service: 'lambda.amazonaws.com'
858
+ });
998
859
 
999
- role = new cf.shortcuts.ServiceRole({
1000
- LogicalName: 'MyRole',
1001
- Service: 'ec2'
860
+ const template = cf.merge(role);
861
+ if (update) fixtures.update('service-role-no-url-suffix', template);
862
+ expect(noUndefined(template)).toEqual(fixtures.get('service-role-no-url-suffix'));
1002
863
  });
1003
864
 
1004
- template = cf.merge(role);
1005
- if (update) fixtures.update('service-role-url-suffix', template);
1006
- assert.deepEqual(
1007
- noUndefined(template),
1008
- fixtures.get('service-role-url-suffix'),
1009
- 'expected resources generated, service for which AWS::URLSuffix is invalid'
1010
- );
865
+ test('expected resources generated, service for which AWS::URLSuffix is valid', () => {
866
+ const role = new cf.shortcuts.ServiceRole({
867
+ LogicalName: 'MyRole',
868
+ Service: 'ec2'
869
+ });
1011
870
 
1012
- role = new cf.shortcuts.ServiceRole({
1013
- LogicalName: 'MyRole',
1014
- Service: 'ec2.amazonaws.com'
871
+ const template = cf.merge(role);
872
+ if (update) fixtures.update('service-role-url-suffix', template);
873
+ expect(noUndefined(template)).toEqual(fixtures.get('service-role-url-suffix'));
1015
874
  });
1016
875
 
1017
- template = cf.merge(role);
1018
- if (update)
1019
- fixtures.update('service-role-url-suffix-with-replacement', template);
1020
- assert.deepEqual(
1021
- noUndefined(template),
1022
- fixtures.get('service-role-url-suffix-with-replacement'),
1023
- 'expected resources generated, service for which AWS::URLSuffix is invalid specified with a suffix'
1024
- );
876
+ test('expected resources generated, service for which AWS::URLSuffix is invalid specified with a suffix', () => {
877
+ const role = new cf.shortcuts.ServiceRole({
878
+ LogicalName: 'MyRole',
879
+ Service: 'ec2.amazonaws.com'
880
+ });
1025
881
 
1026
- role = new cf.shortcuts.ServiceRole({
1027
- LogicalName: 'MyRole',
1028
- Service: 'lambda.amazonaws.com',
1029
- Statement: [
1030
- {
1031
- Effect: 'Allow',
1032
- Action: 's3:GetObject',
1033
- Resource: 'arn:aws:s3:::fake/data'
1034
- }
1035
- ],
1036
- ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
1037
- MaxSessionDuration: 3600,
1038
- Path: '/fake/',
1039
- RoleName: 'my-role',
1040
- Condition: 'Always',
1041
- DependsOn: 'AnotherThing'
1042
- });
1043
-
1044
- template = cf.merge(
1045
- { Conditions: { Always: cf.equals('1', '1') } },
1046
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1047
- role
1048
- );
1049
- if (update) fixtures.update('service-role-no-defaults', template);
1050
- assert.deepEqual(
1051
- noUndefined(template),
1052
- fixtures.get('service-role-no-defaults'),
1053
- 'expected resources generated without defaults'
1054
- );
882
+ const template = cf.merge(role);
883
+ if (update) fixtures.update('service-role-url-suffix-with-replacement', template);
884
+ expect(noUndefined(template)).toEqual(fixtures.get('service-role-url-suffix-with-replacement'));
885
+ });
886
+
887
+ test('expected resources generated without defaults', () => {
888
+ const role = new cf.shortcuts.ServiceRole({
889
+ LogicalName: 'MyRole',
890
+ Service: 'lambda.amazonaws.com',
891
+ Statement: [
892
+ {
893
+ Effect: 'Allow',
894
+ Action: 's3:GetObject',
895
+ Resource: 'arn:aws:s3:::fake/data'
896
+ }
897
+ ],
898
+ ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
899
+ MaxSessionDuration: 3600,
900
+ Path: '/fake/',
901
+ RoleName: 'my-role',
902
+ Condition: 'Always',
903
+ DependsOn: 'AnotherThing'
904
+ });
1055
905
 
1056
- assert.end();
906
+ const template = cf.merge(
907
+ { Conditions: { Always: cf.equals('1', '1') } },
908
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
909
+ role
910
+ );
911
+ if (update) fixtures.update('service-role-no-defaults', template);
912
+ expect(noUndefined(template)).toEqual(fixtures.get('service-role-no-defaults'));
913
+ });
1057
914
  });
1058
915
 
1059
- test('[shortcuts] glue database', (assert) => {
1060
- assert.throws(
1061
- () => new cf.shortcuts.GlueDatabase(),
1062
- 'Options required',
1063
- 'throws without options'
1064
- );
1065
- assert.throws(
1066
- () => new cf.shortcuts.GlueDatabase({}),
1067
- /You must provide a LogicalName and Name/,
1068
- 'throws without required parameters'
1069
- );
916
+ describe('[shortcuts] glue database', () => {
917
+ test('throws without options', () => {
918
+ expect(() => new cf.shortcuts.GlueDatabase()).toThrow('Options required');
919
+ });
1070
920
 
1071
- let db = new cf.shortcuts.GlueDatabase({
1072
- LogicalName: 'MyDatabase',
1073
- Name: 'my_database'
921
+ test('throws without required parameters', () => {
922
+ expect(() => new cf.shortcuts.GlueDatabase({})).toThrow(/You must provide a LogicalName and Name/);
1074
923
  });
1075
924
 
1076
- let template = cf.merge(db);
1077
- if (update) fixtures.update('glue-database-defaults', template);
1078
- assert.deepEqual(
1079
- noUndefined(template),
1080
- fixtures.get('glue-database-defaults'),
1081
- 'expected resources generated with defaults'
1082
- );
925
+ test('expected resources generated with defaults', () => {
926
+ const db = new cf.shortcuts.GlueDatabase({
927
+ LogicalName: 'MyDatabase',
928
+ Name: 'my_database'
929
+ });
1083
930
 
1084
- db = new cf.shortcuts.GlueDatabase({
1085
- LogicalName: 'MyDatabase',
1086
- Name: 'my_database',
1087
- CatalogId: '123456',
1088
- Description: 'my_database description',
1089
- LocationUri: 'fakeuri',
1090
- Parameters: { thing: 'a' },
1091
- Condition: 'Always',
1092
- DependsOn: 'AnotherThing'
1093
- });
1094
-
1095
- template = cf.merge(
1096
- { Conditions: { Always: cf.equals('1', '1') } },
1097
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1098
- db
1099
- );
1100
- if (update) fixtures.update('glue-database-no-defaults', template);
1101
- assert.deepEqual(
1102
- noUndefined(template),
1103
- fixtures.get('glue-database-no-defaults'),
1104
- 'expected resources generated without defaults'
1105
- );
931
+ const template = cf.merge(db);
932
+ if (update) fixtures.update('glue-database-defaults', template);
933
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-database-defaults'));
934
+ });
935
+
936
+ test('expected resources generated without defaults', () => {
937
+ const db = new cf.shortcuts.GlueDatabase({
938
+ LogicalName: 'MyDatabase',
939
+ Name: 'my_database',
940
+ CatalogId: '123456',
941
+ Description: 'my_database description',
942
+ LocationUri: 'fakeuri',
943
+ Parameters: { thing: 'a' },
944
+ Condition: 'Always',
945
+ DependsOn: 'AnotherThing'
946
+ });
1106
947
 
1107
- assert.end();
948
+ const template = cf.merge(
949
+ { Conditions: { Always: cf.equals('1', '1') } },
950
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
951
+ db
952
+ );
953
+ if (update) fixtures.update('glue-database-no-defaults', template);
954
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-database-no-defaults'));
955
+ });
1108
956
  });
1109
957
 
1110
- test('[shortcuts] glue table', (assert) => {
1111
- assert.throws(
1112
- () => new cf.shortcuts.GlueTable(),
1113
- 'Options required',
1114
- 'throws without options'
1115
- );
1116
- assert.throws(
1117
- () => new cf.shortcuts.GlueTable({}),
1118
- /You must provide a LogicalName, Name, DatabaseName, and Columns/,
1119
- 'throws without required parameters'
1120
- );
958
+ describe('[shortcuts] glue table', () => {
959
+ test('throws without options', () => {
960
+ expect(() => new cf.shortcuts.GlueTable()).toThrow('Options required');
961
+ });
1121
962
 
1122
- let db = new cf.shortcuts.GlueTable({
1123
- LogicalName: 'MyTable',
1124
- DatabaseName: 'my_database',
1125
- Name: 'my_table',
1126
- Columns: [
1127
- { Name: 'column', Type: 'string' }
1128
- ]
1129
- });
1130
-
1131
- let template = cf.merge(db);
1132
- if (update) fixtures.update('glue-table-defaults', template);
1133
- assert.deepEqual(
1134
- noUndefined(template),
1135
- fixtures.get('glue-table-defaults'),
1136
- 'expected resources generated with defaults'
1137
- );
963
+ test('throws without required parameters', () => {
964
+ expect(() => new cf.shortcuts.GlueTable({})).toThrow(/You must provide a LogicalName, Name, DatabaseName, and Columns/);
965
+ });
1138
966
 
1139
- db = new cf.shortcuts.GlueTable({
1140
- LogicalName: 'MyTable',
1141
- DatabaseName: 'my_database',
1142
- Name: 'my_table',
1143
- Columns: [
1144
- { Name: 'column', Type: 'string' }
1145
- ],
1146
- CatalogId: '1234',
1147
- Owner: 'Team',
1148
- Parameters: { table: 'params' },
1149
- Description: 'my_table description',
1150
- Retention: 12,
1151
- TableType: 'EXTERNAL_TABLE',
1152
- ViewExpandedText: '/* Presto View */',
1153
- ViewOriginalText: '/* Presto View: abc123= */',
1154
- BucketColumns: ['column'],
1155
- Compressed: true,
1156
- InputFormat: 'fake.input.format',
1157
- Location: 's3://fake/location',
1158
- OutputFormat: 'fake.output.format',
1159
- StorageParameters: { storage: 'parameters' },
1160
- SerdeInfo: {
1161
- SerializationLibrary: 'fake.serde'
1162
- },
1163
- SkewedColumns: {
1164
- SkewedColumnNames: ['column'],
1165
- SkewedColumnValueLocationMap: { fake: 'map' },
1166
- SkewedColumnValues: ['value']
1167
- },
1168
- SortColumns: [
1169
- { Column: 'column', SortOrder: 0 }
1170
- ],
1171
- StoredAsSubdirectory: true,
1172
- Condition: 'Always',
1173
- DependsOn: 'AnotherThing'
1174
- });
1175
-
1176
- template = cf.merge(
1177
- { Conditions: { Always: cf.equals('1', '1') } },
1178
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1179
- db
1180
- );
1181
- if (update) fixtures.update('glue-table-no-defaults', template);
1182
- assert.deepEqual(
1183
- noUndefined(template),
1184
- fixtures.get('glue-table-no-defaults'),
1185
- 'expected resources generated without defaults'
1186
- );
967
+ test('expected resources generated with defaults', () => {
968
+ const db = new cf.shortcuts.GlueTable({
969
+ LogicalName: 'MyTable',
970
+ DatabaseName: 'my_database',
971
+ Name: 'my_table',
972
+ Columns: [
973
+ { Name: 'column', Type: 'string' }
974
+ ]
975
+ });
976
+
977
+ const template = cf.merge(db);
978
+ if (update) fixtures.update('glue-table-defaults', template);
979
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-table-defaults'));
980
+ });
1187
981
 
1188
- assert.end();
982
+ test('expected resources generated without defaults', () => {
983
+ const db = new cf.shortcuts.GlueTable({
984
+ LogicalName: 'MyTable',
985
+ DatabaseName: 'my_database',
986
+ Name: 'my_table',
987
+ Columns: [
988
+ { Name: 'column', Type: 'string' }
989
+ ],
990
+ CatalogId: '1234',
991
+ Owner: 'Team',
992
+ Parameters: { table: 'params' },
993
+ Description: 'my_table description',
994
+ Retention: 12,
995
+ TableType: 'EXTERNAL_TABLE',
996
+ ViewExpandedText: '/* Presto View */',
997
+ ViewOriginalText: '/* Presto View: abc123= */',
998
+ BucketColumns: ['column'],
999
+ Compressed: true,
1000
+ InputFormat: 'fake.input.format',
1001
+ Location: 's3://fake/location',
1002
+ OutputFormat: 'fake.output.format',
1003
+ StorageParameters: { storage: 'parameters' },
1004
+ SerdeInfo: {
1005
+ SerializationLibrary: 'fake.serde'
1006
+ },
1007
+ SkewedColumns: {
1008
+ SkewedColumnNames: ['column'],
1009
+ SkewedColumnValueLocationMap: { fake: 'map' },
1010
+ SkewedColumnValues: ['value']
1011
+ },
1012
+ SortColumns: [
1013
+ { Column: 'column', SortOrder: 0 }
1014
+ ],
1015
+ StoredAsSubdirectory: true,
1016
+ Condition: 'Always',
1017
+ DependsOn: 'AnotherThing'
1018
+ });
1019
+
1020
+ const template = cf.merge(
1021
+ { Conditions: { Always: cf.equals('1', '1') } },
1022
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1023
+ db
1024
+ );
1025
+ if (update) fixtures.update('glue-table-no-defaults', template);
1026
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-table-no-defaults'));
1027
+ });
1189
1028
  });
1190
1029
 
1191
- test('[shortcuts] glue json table', (assert) => {
1192
- assert.throws(
1193
- () => new cf.shortcuts.GlueJsonTable(),
1194
- 'Options required',
1195
- 'throws without options'
1196
- );
1197
- assert.throws(
1198
- () => new cf.shortcuts.GlueJsonTable({}),
1199
- /You must provide a Location/,
1200
- 'throws without required parameters'
1201
- );
1030
+ describe('[shortcuts] glue json table', () => {
1031
+ test('throws without options', () => {
1032
+ expect(() => new cf.shortcuts.GlueJsonTable()).toThrow('Options required');
1033
+ });
1202
1034
 
1203
- let db = new cf.shortcuts.GlueJsonTable({
1204
- LogicalName: 'MyTable',
1205
- DatabaseName: 'my_database',
1206
- Name: 'my_table',
1207
- Columns: [
1208
- { Name: 'column', Type: 'string' }
1209
- ],
1210
- Location: 's3://fake/location'
1211
- });
1212
-
1213
- let template = cf.merge(db);
1214
- if (update) fixtures.update('glue-json-table-defaults', template);
1215
- assert.deepEqual(
1216
- noUndefined(template),
1217
- fixtures.get('glue-json-table-defaults'),
1218
- 'expected resources generated with defaults'
1219
- );
1035
+ test('throws without required parameters', () => {
1036
+ expect(() => new cf.shortcuts.GlueJsonTable({})).toThrow(/You must provide a Location/);
1037
+ });
1220
1038
 
1221
- db = new cf.shortcuts.GlueJsonTable({
1222
- LogicalName: 'MyTable',
1223
- DatabaseName: 'my_database',
1224
- Name: 'my_table',
1225
- Columns: [
1226
- { Name: 'column', Type: 'string' }
1227
- ],
1228
- CatalogId: '1234',
1229
- Owner: 'Team',
1230
- Parameters: { table: 'params' },
1231
- Description: 'my_table description',
1232
- Retention: 12,
1233
- TableType: 'EXTERNAL_TABLE',
1234
- ViewExpandedText: '/* Presto View */',
1235
- ViewOriginalText: '/* Presto View: abc123= */',
1236
- BucketColumns: ['column'],
1237
- Compressed: true,
1238
- Location: 's3://fake/location',
1239
- InputFormat: 'fake.input.format',
1240
- OutputFormat: 'fake.output.format',
1241
- StorageParameters: { storage: 'parameters' },
1242
- SerdeInfo: {
1243
- SerializationLibrary: 'fake.serde'
1244
- },
1245
- SkewedColumns: {
1246
- SkewedColumnNames: ['column'],
1247
- SkewedColumnValueLocationMap: { fake: 'map' },
1248
- SkewedColumnValues: ['value']
1249
- },
1250
- SortColumns: [
1251
- { Column: 'column', SortOrder: 0 }
1252
- ],
1253
- StoredAsSubdirectory: true,
1254
- Condition: 'Always',
1255
- DependsOn: 'AnotherThing'
1256
- });
1257
-
1258
- template = cf.merge(
1259
- { Conditions: { Always: cf.equals('1', '1') } },
1260
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1261
- db
1262
- );
1263
- if (update) fixtures.update('glue-json-table-no-defaults', template);
1264
- assert.deepEqual(
1265
- noUndefined(template),
1266
- fixtures.get('glue-json-table-no-defaults'),
1267
- 'expected resources generated without defaults'
1268
- );
1039
+ test('expected resources generated with defaults', () => {
1040
+ const db = new cf.shortcuts.GlueJsonTable({
1041
+ LogicalName: 'MyTable',
1042
+ DatabaseName: 'my_database',
1043
+ Name: 'my_table',
1044
+ Columns: [
1045
+ { Name: 'column', Type: 'string' }
1046
+ ],
1047
+ Location: 's3://fake/location'
1048
+ });
1269
1049
 
1270
- assert.end();
1050
+ const template = cf.merge(db);
1051
+ if (update) fixtures.update('glue-json-table-defaults', template);
1052
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-json-table-defaults'));
1053
+ });
1054
+
1055
+ test('expected resources generated without defaults', () => {
1056
+ const db = new cf.shortcuts.GlueJsonTable({
1057
+ LogicalName: 'MyTable',
1058
+ DatabaseName: 'my_database',
1059
+ Name: 'my_table',
1060
+ Columns: [
1061
+ { Name: 'column', Type: 'string' }
1062
+ ],
1063
+ CatalogId: '1234',
1064
+ Owner: 'Team',
1065
+ Parameters: { table: 'params' },
1066
+ Description: 'my_table description',
1067
+ Retention: 12,
1068
+ TableType: 'EXTERNAL_TABLE',
1069
+ ViewExpandedText: '/* Presto View */',
1070
+ ViewOriginalText: '/* Presto View: abc123= */',
1071
+ BucketColumns: ['column'],
1072
+ Compressed: true,
1073
+ Location: 's3://fake/location',
1074
+ InputFormat: 'fake.input.format',
1075
+ OutputFormat: 'fake.output.format',
1076
+ StorageParameters: { storage: 'parameters' },
1077
+ SerdeInfo: {
1078
+ SerializationLibrary: 'fake.serde'
1079
+ },
1080
+ SkewedColumns: {
1081
+ SkewedColumnNames: ['column'],
1082
+ SkewedColumnValueLocationMap: { fake: 'map' },
1083
+ SkewedColumnValues: ['value']
1084
+ },
1085
+ SortColumns: [
1086
+ { Column: 'column', SortOrder: 0 }
1087
+ ],
1088
+ StoredAsSubdirectory: true,
1089
+ Condition: 'Always',
1090
+ DependsOn: 'AnotherThing'
1091
+ });
1092
+
1093
+ const template = cf.merge(
1094
+ { Conditions: { Always: cf.equals('1', '1') } },
1095
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1096
+ db
1097
+ );
1098
+ if (update) fixtures.update('glue-json-table-no-defaults', template);
1099
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-json-table-no-defaults'));
1100
+ });
1271
1101
  });
1272
1102
 
1273
- test('[shortcuts] glue orc table', (assert) => {
1274
- assert.throws(
1275
- () => new cf.shortcuts.GlueOrcTable(),
1276
- 'Options required',
1277
- 'throws without options'
1278
- );
1279
- assert.throws(
1280
- () => new cf.shortcuts.GlueOrcTable({}),
1281
- /You must provide a Location/,
1282
- 'throws without required parameters'
1283
- );
1103
+ describe('[shortcuts] glue orc table', () => {
1104
+ test('throws without options', () => {
1105
+ expect(() => new cf.shortcuts.GlueOrcTable()).toThrow('Options required');
1106
+ });
1284
1107
 
1285
- let db = new cf.shortcuts.GlueOrcTable({
1286
- LogicalName: 'MyTable',
1287
- DatabaseName: 'my_database',
1288
- Name: 'my_table',
1289
- Columns: [
1290
- { Name: 'column', Type: 'string' }
1291
- ],
1292
- Location: 's3://fake/location'
1293
- });
1294
-
1295
- let template = cf.merge(db);
1296
- if (update) fixtures.update('glue-orc-table-defaults', template);
1297
- assert.deepEqual(
1298
- noUndefined(template),
1299
- fixtures.get('glue-orc-table-defaults'),
1300
- 'expected resources generated with defaults'
1301
- );
1108
+ test('throws without required parameters', () => {
1109
+ expect(() => new cf.shortcuts.GlueOrcTable({})).toThrow(/You must provide a Location/);
1110
+ });
1302
1111
 
1303
- db = new cf.shortcuts.GlueOrcTable({
1304
- LogicalName: 'MyTable',
1305
- DatabaseName: 'my_database',
1306
- Name: 'my_table',
1307
- Columns: [
1308
- { Name: 'column', Type: 'string' }
1309
- ],
1310
- CatalogId: '1234',
1311
- Owner: 'Team',
1312
- Parameters: { table: 'params' },
1313
- Description: 'my_table description',
1314
- Retention: 12,
1315
- TableType: 'EXTERNAL_TABLE',
1316
- ViewExpandedText: '/* Presto View */',
1317
- ViewOriginalText: '/* Presto View: abc123= */',
1318
- BucketColumns: ['column'],
1319
- Compressed: true,
1320
- Location: 's3://fake/location',
1321
- InputFormat: 'fake.input.format',
1322
- OutputFormat: 'fake.output.format',
1323
- StorageParameters: { storage: 'parameters' },
1324
- SerdeInfo: {
1325
- SerializationLibrary: 'fake.serde'
1326
- },
1327
- SkewedColumns: {
1328
- SkewedColumnNames: ['column'],
1329
- SkewedColumnValueLocationMap: { fake: 'map' },
1330
- SkewedColumnValues: ['value']
1331
- },
1332
- SortColumns: [
1333
- { Column: 'column', SortOrder: 0 }
1334
- ],
1335
- StoredAsSubdirectory: true,
1336
- Condition: 'Always',
1337
- DependsOn: 'AnotherThing'
1338
- });
1339
-
1340
- template = cf.merge(
1341
- { Conditions: { Always: cf.equals('1', '1') } },
1342
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1343
- db
1344
- );
1345
- if (update) fixtures.update('glue-orc-table-no-defaults', template);
1346
- assert.deepEqual(
1347
- noUndefined(template),
1348
- fixtures.get('glue-orc-table-no-defaults'),
1349
- 'expected resources generated without defaults'
1350
- );
1112
+ test('expected resources generated with defaults', () => {
1113
+ const db = new cf.shortcuts.GlueOrcTable({
1114
+ LogicalName: 'MyTable',
1115
+ DatabaseName: 'my_database',
1116
+ Name: 'my_table',
1117
+ Columns: [
1118
+ { Name: 'column', Type: 'string' }
1119
+ ],
1120
+ Location: 's3://fake/location'
1121
+ });
1122
+
1123
+ const template = cf.merge(db);
1124
+ if (update) fixtures.update('glue-orc-table-defaults', template);
1125
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-orc-table-defaults'));
1126
+ });
1127
+
1128
+ test('expected resources generated without defaults', () => {
1129
+ const db = new cf.shortcuts.GlueOrcTable({
1130
+ LogicalName: 'MyTable',
1131
+ DatabaseName: 'my_database',
1132
+ Name: 'my_table',
1133
+ Columns: [
1134
+ { Name: 'column', Type: 'string' }
1135
+ ],
1136
+ CatalogId: '1234',
1137
+ Owner: 'Team',
1138
+ Parameters: { table: 'params' },
1139
+ Description: 'my_table description',
1140
+ Retention: 12,
1141
+ TableType: 'EXTERNAL_TABLE',
1142
+ ViewExpandedText: '/* Presto View */',
1143
+ ViewOriginalText: '/* Presto View: abc123= */',
1144
+ BucketColumns: ['column'],
1145
+ Compressed: true,
1146
+ Location: 's3://fake/location',
1147
+ InputFormat: 'fake.input.format',
1148
+ OutputFormat: 'fake.output.format',
1149
+ StorageParameters: { storage: 'parameters' },
1150
+ SerdeInfo: {
1151
+ SerializationLibrary: 'fake.serde'
1152
+ },
1153
+ SkewedColumns: {
1154
+ SkewedColumnNames: ['column'],
1155
+ SkewedColumnValueLocationMap: { fake: 'map' },
1156
+ SkewedColumnValues: ['value']
1157
+ },
1158
+ SortColumns: [
1159
+ { Column: 'column', SortOrder: 0 }
1160
+ ],
1161
+ StoredAsSubdirectory: true,
1162
+ Condition: 'Always',
1163
+ DependsOn: 'AnotherThing'
1164
+ });
1351
1165
 
1352
- assert.end();
1166
+ const template = cf.merge(
1167
+ { Conditions: { Always: cf.equals('1', '1') } },
1168
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1169
+ db
1170
+ );
1171
+ if (update) fixtures.update('glue-orc-table-no-defaults', template);
1172
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-orc-table-no-defaults'));
1173
+ });
1353
1174
  });
1354
1175
 
1355
- test('[shortcuts] glue parquet table', (assert) => {
1356
- assert.throws(
1357
- () => new cf.shortcuts.GlueParquetTable(),
1358
- 'Options required',
1359
- 'throws without options'
1360
- );
1361
- assert.throws(
1362
- () => new cf.shortcuts.GlueParquetTable({}),
1363
- /You must provide a Location/,
1364
- 'throws without required parameters'
1365
- );
1176
+ describe('[shortcuts] glue parquet table', () => {
1177
+ test('throws without options', () => {
1178
+ expect(() => new cf.shortcuts.GlueParquetTable()).toThrow('Options required');
1179
+ });
1366
1180
 
1367
- let db = new cf.shortcuts.GlueParquetTable({
1368
- LogicalName: 'MyTable',
1369
- DatabaseName: 'my_database',
1370
- Name: 'my_table',
1371
- Columns: [
1372
- { Name: 'column', Type: 'string' }
1373
- ],
1374
- Location: 's3://fake/location'
1375
- });
1376
-
1377
- let template = cf.merge(db);
1378
- if (update) fixtures.update('glue-parquet-table-defaults', template);
1379
- assert.deepEqual(
1380
- noUndefined(template),
1381
- fixtures.get('glue-parquet-table-defaults'),
1382
- 'expected resources generated with defaults'
1383
- );
1181
+ test('throws without required parameters', () => {
1182
+ expect(() => new cf.shortcuts.GlueParquetTable({})).toThrow(/You must provide a Location/);
1183
+ });
1384
1184
 
1385
- db = new cf.shortcuts.GlueParquetTable({
1386
- LogicalName: 'MyTable',
1387
- DatabaseName: 'my_database',
1388
- Name: 'my_table',
1389
- Columns: [
1390
- { Name: 'column', Type: 'string' }
1391
- ],
1392
- CatalogId: '1234',
1393
- Owner: 'Team',
1394
- Parameters: { table: 'params' },
1395
- Description: 'my_table description',
1396
- Retention: 12,
1397
- TableType: 'EXTERNAL_TABLE',
1398
- ViewExpandedText: '/* Presto View */',
1399
- ViewOriginalText: '/* Presto View: abc123= */',
1400
- BucketColumns: ['column'],
1401
- Compressed: true,
1402
- Location: 's3://fake/location',
1403
- InputFormat: 'fake.input.format',
1404
- OutputFormat: 'fake.output.format',
1405
- StorageParameters: { storage: 'parameters' },
1406
- SerdeInfo: {
1407
- SerializationLibrary: 'fake.serde'
1408
- },
1409
- SkewedColumns: {
1410
- SkewedColumnNames: ['column'],
1411
- SkewedColumnValueLocationMap: { fake: 'map' },
1412
- SkewedColumnValues: ['value']
1413
- },
1414
- SortColumns: [
1415
- { Column: 'column', SortOrder: 0 }
1416
- ],
1417
- StoredAsSubdirectory: true,
1418
- Condition: 'Always',
1419
- DependsOn: 'AnotherThing'
1420
- });
1421
-
1422
- template = cf.merge(
1423
- { Conditions: { Always: cf.equals('1', '1') } },
1424
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1425
- db
1426
- );
1427
- if (update) fixtures.update('glue-parquet-table-no-defaults', template);
1428
- assert.deepEqual(
1429
- noUndefined(template),
1430
- fixtures.get('glue-parquet-table-no-defaults'),
1431
- 'expected resources generated without defaults'
1432
- );
1185
+ test('expected resources generated with defaults', () => {
1186
+ const db = new cf.shortcuts.GlueParquetTable({
1187
+ LogicalName: 'MyTable',
1188
+ DatabaseName: 'my_database',
1189
+ Name: 'my_table',
1190
+ Columns: [
1191
+ { Name: 'column', Type: 'string' }
1192
+ ],
1193
+ Location: 's3://fake/location'
1194
+ });
1195
+
1196
+ const template = cf.merge(db);
1197
+ if (update) fixtures.update('glue-parquet-table-defaults', template);
1198
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-parquet-table-defaults'));
1199
+ });
1200
+
1201
+ test('expected resources generated without defaults', () => {
1202
+ const db = new cf.shortcuts.GlueParquetTable({
1203
+ LogicalName: 'MyTable',
1204
+ DatabaseName: 'my_database',
1205
+ Name: 'my_table',
1206
+ Columns: [
1207
+ { Name: 'column', Type: 'string' }
1208
+ ],
1209
+ CatalogId: '1234',
1210
+ Owner: 'Team',
1211
+ Parameters: { table: 'params' },
1212
+ Description: 'my_table description',
1213
+ Retention: 12,
1214
+ TableType: 'EXTERNAL_TABLE',
1215
+ ViewExpandedText: '/* Presto View */',
1216
+ ViewOriginalText: '/* Presto View: abc123= */',
1217
+ BucketColumns: ['column'],
1218
+ Compressed: true,
1219
+ Location: 's3://fake/location',
1220
+ InputFormat: 'fake.input.format',
1221
+ OutputFormat: 'fake.output.format',
1222
+ StorageParameters: { storage: 'parameters' },
1223
+ SerdeInfo: {
1224
+ SerializationLibrary: 'fake.serde'
1225
+ },
1226
+ SkewedColumns: {
1227
+ SkewedColumnNames: ['column'],
1228
+ SkewedColumnValueLocationMap: { fake: 'map' },
1229
+ SkewedColumnValues: ['value']
1230
+ },
1231
+ SortColumns: [
1232
+ { Column: 'column', SortOrder: 0 }
1233
+ ],
1234
+ StoredAsSubdirectory: true,
1235
+ Condition: 'Always',
1236
+ DependsOn: 'AnotherThing'
1237
+ });
1433
1238
 
1434
- assert.end();
1239
+ const template = cf.merge(
1240
+ { Conditions: { Always: cf.equals('1', '1') } },
1241
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1242
+ db
1243
+ );
1244
+ if (update) fixtures.update('glue-parquet-table-no-defaults', template);
1245
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-parquet-table-no-defaults'));
1246
+ });
1435
1247
  });
1436
1248
 
1437
- test('[shortcuts] glue view', (assert) => {
1438
- assert.throws(
1439
- () => new cf.shortcuts.GluePrestoView(),
1440
- 'Options required',
1441
- 'throws without options'
1442
- );
1443
- assert.throws(
1444
- () => new cf.shortcuts.GluePrestoView({}),
1445
- /You must provide a DatabaseName, Columns, and OriginalSql/,
1446
- 'throws without required parameters'
1447
- );
1249
+ describe('[shortcuts] glue view', () => {
1250
+ test('throws without options', () => {
1251
+ expect(() => new cf.shortcuts.GluePrestoView()).toThrow('Options required');
1252
+ });
1448
1253
 
1449
- let db = new cf.shortcuts.GluePrestoView({
1450
- LogicalName: 'MyView',
1451
- DatabaseName: 'my_database',
1452
- Name: 'my_view',
1453
- Columns: [
1454
- { Name: 'column', Type: 'string' }
1455
- ],
1456
- OriginalSql: 'SELECT * FROM another.table'
1457
- });
1458
-
1459
- let template = cf.merge(db);
1460
- if (update) fixtures.update('glue-view-defaults', template);
1461
- assert.deepEqual(
1462
- noUndefined(template),
1463
- fixtures.get('glue-view-defaults'),
1464
- 'expected resources generated with defaults'
1465
- );
1254
+ test('throws without required parameters', () => {
1255
+ expect(() => new cf.shortcuts.GluePrestoView({})).toThrow(/You must provide a DatabaseName, Columns, and OriginalSql/);
1256
+ });
1466
1257
 
1467
- db = new cf.shortcuts.GluePrestoView({
1468
- LogicalName: 'MyTable',
1469
- DatabaseName: 'my_database',
1470
- Name: 'my_view',
1471
- Columns: [
1472
- { Name: 'column', Type: 'string' }
1473
- ],
1474
- OriginalSql: 'SELECT * FROM another.table',
1475
- CatalogId: '1234',
1476
- Owner: 'Team',
1477
- Parameters: { table: 'params' },
1478
- Description: 'my_view description',
1479
- Retention: 12,
1480
- TableType: 'EXTERNAL_TABLE',
1481
- BucketColumns: ['column'],
1482
- Compressed: true,
1483
- Location: 's3://fake/location',
1484
- InputFormat: 'fake.input.format',
1485
- OutputFormat: 'fake.output.format',
1486
- StorageParameters: { storage: 'parameters' },
1487
- SerdeInfo: {
1488
- SerializationLibrary: 'fake.serde'
1489
- },
1490
- SkewedColumns: {
1491
- SkewedColumnNames: ['column'],
1492
- SkewedColumnValueLocationMap: { fake: 'map' },
1493
- SkewedColumnValues: ['value']
1494
- },
1495
- SortColumns: [
1496
- { Column: 'column', SortOrder: 0 }
1497
- ],
1498
- StoredAsSubdirectory: true,
1499
- SqlVariables: { env: { Ref: 'AWS::StackName' } },
1500
- Condition: 'Always',
1501
- DependsOn: 'AnotherThing'
1502
- });
1503
-
1504
- template = cf.merge(
1505
- { Conditions: { Always: cf.equals('1', '1') } },
1506
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1507
- db
1508
- );
1509
- if (update) fixtures.update('glue-view-no-defaults', template);
1510
- assert.deepEqual(
1511
- noUndefined(template),
1512
- fixtures.get('glue-view-no-defaults'),
1513
- 'expected resources generated without defaults'
1514
- );
1258
+ test('expected resources generated with defaults', () => {
1259
+ const db = new cf.shortcuts.GluePrestoView({
1260
+ LogicalName: 'MyView',
1261
+ DatabaseName: 'my_database',
1262
+ Name: 'my_view',
1263
+ Columns: [
1264
+ { Name: 'column', Type: 'string' }
1265
+ ],
1266
+ OriginalSql: 'SELECT * FROM another.table'
1267
+ });
1515
1268
 
1516
- assert.end();
1269
+ const template = cf.merge(db);
1270
+ if (update) fixtures.update('glue-view-defaults', template);
1271
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-view-defaults'));
1272
+ });
1273
+
1274
+ test('expected resources generated without defaults', () => {
1275
+ const db = new cf.shortcuts.GluePrestoView({
1276
+ LogicalName: 'MyTable',
1277
+ DatabaseName: 'my_database',
1278
+ Name: 'my_view',
1279
+ Columns: [
1280
+ { Name: 'column', Type: 'string' }
1281
+ ],
1282
+ OriginalSql: 'SELECT * FROM another.table',
1283
+ CatalogId: '1234',
1284
+ Owner: 'Team',
1285
+ Parameters: { table: 'params' },
1286
+ Description: 'my_view description',
1287
+ Retention: 12,
1288
+ TableType: 'EXTERNAL_TABLE',
1289
+ BucketColumns: ['column'],
1290
+ Compressed: true,
1291
+ Location: 's3://fake/location',
1292
+ InputFormat: 'fake.input.format',
1293
+ OutputFormat: 'fake.output.format',
1294
+ StorageParameters: { storage: 'parameters' },
1295
+ SerdeInfo: {
1296
+ SerializationLibrary: 'fake.serde'
1297
+ },
1298
+ SkewedColumns: {
1299
+ SkewedColumnNames: ['column'],
1300
+ SkewedColumnValueLocationMap: { fake: 'map' },
1301
+ SkewedColumnValues: ['value']
1302
+ },
1303
+ SortColumns: [
1304
+ { Column: 'column', SortOrder: 0 }
1305
+ ],
1306
+ StoredAsSubdirectory: true,
1307
+ SqlVariables: { env: { Ref: 'AWS::StackName' } },
1308
+ Condition: 'Always',
1309
+ DependsOn: 'AnotherThing'
1310
+ });
1311
+
1312
+ const template = cf.merge(
1313
+ { Conditions: { Always: cf.equals('1', '1') } },
1314
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1315
+ db
1316
+ );
1317
+ if (update) fixtures.update('glue-view-no-defaults', template);
1318
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-view-no-defaults'));
1319
+ });
1517
1320
  });
1518
1321
 
1519
1322
  const normalizeDeployment = (template) => {
@@ -1524,230 +1327,192 @@ const normalizeDeployment = (template) => {
1524
1327
  return JSON.parse(str);
1525
1328
  };
1526
1329
 
1527
- test('[shortcuts] hookshot passthrough', (assert) => {
1528
- assert.throws(
1529
- () => new cf.shortcuts.hookshot.Passthrough(),
1530
- 'Options required',
1531
- 'throws without options'
1532
- );
1533
- assert.throws(
1534
- () => new cf.shortcuts.hookshot.Passthrough({}),
1535
- /You must provide a Prefix, and PassthroughTo/,
1536
- 'throws without required parameters'
1537
- );
1330
+ describe('[shortcuts] hookshot passthrough', () => {
1331
+ test('throws without options', () => {
1332
+ expect(() => new cf.shortcuts.hookshot.Passthrough()).toThrow('Options required');
1333
+ });
1538
1334
 
1539
- assert.throws(
1540
- () =>
1541
- new cf.shortcuts.hookshot.Passthrough({
1542
- Prefix: 'Pass',
1543
- PassthroughTo: 'Destination',
1544
- LoggingLevel: 'HAM'
1545
- }),
1546
- /LoggingLevel must be one of OFF, INFO, or ERROR/,
1547
- 'throws with invalid LoggingLevel'
1548
- );
1335
+ test('throws without required parameters', () => {
1336
+ expect(() => new cf.shortcuts.hookshot.Passthrough({})).toThrow(/You must provide a Prefix, and PassthroughTo/);
1337
+ });
1549
1338
 
1550
- assert.throws(
1551
- () =>
1552
- new cf.shortcuts.hookshot.Passthrough({
1553
- Prefix: 'Pass',
1554
- PassthroughTo: 'Destination',
1555
- LoggingLevel: 'INFO',
1556
- Runtime: 'python3.7'
1557
- }),
1558
- /Only valid nodejs runtimes are supported for hookshot lambdas, received: 'python3.7'/,
1559
- 'throws with invalid lambda Runtime python3.7'
1560
- );
1339
+ test('throws with invalid LoggingLevel', () => {
1340
+ expect(() => new cf.shortcuts.hookshot.Passthrough({
1341
+ Prefix: 'Pass',
1342
+ PassthroughTo: 'Destination',
1343
+ LoggingLevel: 'HAM'
1344
+ })).toThrow(/LoggingLevel must be one of OFF, INFO, or ERROR/);
1345
+ });
1561
1346
 
1562
- assert.throws(
1563
- () =>
1564
- new cf.shortcuts.hookshot.Passthrough({
1565
- Prefix: 'Pass',
1566
- PassthroughTo: 'Destination',
1567
- LoggingLevel: 'INFO',
1568
- Runtime: 'nodejs16.x'
1569
- }),
1570
- /Only nodejs runtimes >= 18 are supported for hookshot lambdas, received: 'nodejs16.x'/,
1571
- 'throws with invalid lambda Runtime nodejs16.x'
1572
- );
1347
+ test('throws with invalid lambda Runtime python3.7', () => {
1348
+ expect(() => new cf.shortcuts.hookshot.Passthrough({
1349
+ Prefix: 'Pass',
1350
+ PassthroughTo: 'Destination',
1351
+ LoggingLevel: 'INFO',
1352
+ Runtime: 'python3.7'
1353
+ })).toThrow(/Only valid nodejs runtimes are supported for hookshot lambdas, received: 'python3.7'/);
1354
+ });
1573
1355
 
1574
- const to = new cf.shortcuts.Lambda({
1356
+ test('throws with invalid lambda Runtime nodejs16.x', () => {
1357
+ expect(() => new cf.shortcuts.hookshot.Passthrough({
1358
+ Prefix: 'Pass',
1359
+ PassthroughTo: 'Destination',
1360
+ LoggingLevel: 'INFO',
1361
+ Runtime: 'nodejs16.x'
1362
+ })).toThrow(/Only nodejs runtimes >= 18 are supported for hookshot lambdas, received: 'nodejs16.x'/);
1363
+ });
1364
+
1365
+ const getDestinationLambda = () => new cf.shortcuts.Lambda({
1575
1366
  LogicalName: 'Destination',
1576
1367
  Code: {
1577
1368
  ZipFile: 'module.exports.handler = (e, c, cb) => cb();'
1578
1369
  }
1579
1370
  });
1580
1371
 
1581
- let passthrough = new cf.shortcuts.hookshot.Passthrough({
1582
- Prefix: 'Pass',
1583
- PassthroughTo: 'Destination'
1372
+ test('expected resources generated with defaults', () => {
1373
+ const to = getDestinationLambda();
1374
+ const passthrough = new cf.shortcuts.hookshot.Passthrough({
1375
+ Prefix: 'Pass',
1376
+ PassthroughTo: 'Destination'
1377
+ });
1378
+
1379
+ const template = cf.merge(passthrough, to);
1380
+ if (update) fixtures.update('hookshot-passthrough', template);
1381
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough')));
1584
1382
  });
1585
1383
 
1586
- let template = cf.merge(passthrough, to);
1587
- if (update) fixtures.update('hookshot-passthrough', template);
1588
- assert.deepEqual(
1589
- normalizeDeployment(noUndefined(template)),
1590
- normalizeDeployment(fixtures.get('hookshot-passthrough')),
1591
- 'expected resources generated with defaults'
1592
- );
1384
+ test('expected resources generated with alarm config', () => {
1385
+ const to = getDestinationLambda();
1386
+ const passthrough = new cf.shortcuts.hookshot.Passthrough({
1387
+ Prefix: 'Pass',
1388
+ PassthroughTo: 'Destination',
1389
+ AlarmActions: ['devnull@mapbox.com']
1390
+ });
1593
1391
 
1594
- passthrough = new cf.shortcuts.hookshot.Passthrough({
1595
- Prefix: 'Pass',
1596
- PassthroughTo: 'Destination',
1597
- AlarmActions: ['devnull@mapbox.com']
1392
+ const template = cf.merge(passthrough, to);
1393
+ if (update) fixtures.update('hookshot-passthrough-alarms', template);
1394
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough-alarms')));
1598
1395
  });
1599
1396
 
1600
- template = cf.merge(passthrough, to);
1601
- if (update) fixtures.update('hookshot-passthrough-alarms', template);
1602
- assert.deepEqual(
1603
- normalizeDeployment(noUndefined(template)),
1604
- normalizeDeployment(fixtures.get('hookshot-passthrough-alarms')),
1605
- 'expected resources generated with alarm config'
1606
- );
1397
+ test('expected resources generated with configured LoggingLevel', () => {
1398
+ const to = getDestinationLambda();
1399
+ const passthrough = new cf.shortcuts.hookshot.Passthrough({
1400
+ Prefix: 'Pass',
1401
+ PassthroughTo: 'Destination',
1402
+ LoggingLevel: 'INFO'
1403
+ });
1607
1404
 
1608
- passthrough = new cf.shortcuts.hookshot.Passthrough({
1609
- Prefix: 'Pass',
1610
- PassthroughTo: 'Destination',
1611
- LoggingLevel: 'INFO'
1405
+ const template = cf.merge(passthrough, to);
1406
+ if (update) fixtures.update('hookshot-passthrough-logging', template);
1407
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough-logging')));
1612
1408
  });
1613
1409
 
1614
- template = cf.merge(passthrough, to);
1615
- if (update) fixtures.update('hookshot-passthrough-logging', template);
1616
- assert.deepEqual(
1617
- normalizeDeployment(noUndefined(template)),
1618
- normalizeDeployment(fixtures.get('hookshot-passthrough-logging')),
1619
- 'expected resources generated with configured LoggingLevel'
1620
- );
1410
+ test('expected resources generated with detailed logging and metrics', () => {
1411
+ const to = getDestinationLambda();
1412
+ const passthrough = new cf.shortcuts.hookshot.Passthrough({
1413
+ Prefix: 'Pass',
1414
+ PassthroughTo: 'Destination',
1415
+ DataTraceEnabled: true,
1416
+ MetricsEnabled: true
1417
+ });
1621
1418
 
1622
- passthrough = new cf.shortcuts.hookshot.Passthrough({
1623
- Prefix: 'Pass',
1624
- PassthroughTo: 'Destination',
1625
- DataTraceEnabled: true,
1626
- MetricsEnabled: true
1419
+ const template = cf.merge(passthrough, to);
1420
+ if (update) fixtures.update('hookshot-passthrough-enhanced-logging', template);
1421
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough-enhanced-logging')));
1627
1422
  });
1628
1423
 
1629
- template = cf.merge(passthrough, to);
1630
- if (update)
1631
- fixtures.update('hookshot-passthrough-enhanced-logging', template);
1632
- assert.deepEqual(
1633
- normalizeDeployment(noUndefined(template)),
1634
- normalizeDeployment(fixtures.get('hookshot-passthrough-enhanced-logging')),
1635
- 'expected resources generated with detailed logging and metrics'
1636
- );
1637
-
1638
- passthrough = new cf.shortcuts.hookshot.Passthrough({
1639
- Prefix: 'Pass',
1640
- PassthroughTo: 'Destination',
1641
- DataTraceEnabled: true,
1642
- MetricsEnabled: true,
1643
- LoggingLevel: 'INFO'
1644
- });
1645
-
1646
- template = cf.merge(passthrough, to);
1647
- if (update)
1648
- fixtures.update('hookshot-passthrough-full-blown-logging', template);
1649
- assert.deepEqual(
1650
- normalizeDeployment(noUndefined(template)),
1651
- normalizeDeployment(
1652
- fixtures.get('hookshot-passthrough-full-blown-logging')
1653
- ),
1654
- 'LoggingLevel respected with detailed logging and metrics'
1655
- );
1424
+ test('LoggingLevel respected with detailed logging and metrics', () => {
1425
+ const to = getDestinationLambda();
1426
+ const passthrough = new cf.shortcuts.hookshot.Passthrough({
1427
+ Prefix: 'Pass',
1428
+ PassthroughTo: 'Destination',
1429
+ DataTraceEnabled: true,
1430
+ MetricsEnabled: true,
1431
+ LoggingLevel: 'INFO'
1432
+ });
1656
1433
 
1657
- passthrough = new cf.shortcuts.hookshot.Passthrough({
1658
- Prefix: 'Pass',
1659
- PassthroughTo: 'Destination',
1660
- AccessLogFormat: '{ "requestId":"$context.requestId" }'
1434
+ const template = cf.merge(passthrough, to);
1435
+ if (update) fixtures.update('hookshot-passthrough-full-blown-logging', template);
1436
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough-full-blown-logging')));
1661
1437
  });
1662
1438
 
1663
- template = cf.merge(passthrough, to);
1664
- if (update)
1665
- fixtures.update('hookshot-passthrough-access-log-format', template);
1666
- assert.deepEqual(
1667
- normalizeDeployment(noUndefined(template)),
1668
- normalizeDeployment(fixtures.get('hookshot-passthrough-access-log-format')),
1669
- 'expected resources generated with access logs'
1670
- );
1439
+ test('expected resources generated with access logs', () => {
1440
+ const to = getDestinationLambda();
1441
+ const passthrough = new cf.shortcuts.hookshot.Passthrough({
1442
+ Prefix: 'Pass',
1443
+ PassthroughTo: 'Destination',
1444
+ AccessLogFormat: '{ "requestId":"$context.requestId" }'
1445
+ });
1671
1446
 
1672
- assert.end();
1447
+ const template = cf.merge(passthrough, to);
1448
+ if (update) fixtures.update('hookshot-passthrough-access-log-format', template);
1449
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough-access-log-format')));
1450
+ });
1673
1451
  });
1674
1452
 
1675
- test('[shortcuts] hookshot github', (assert) => {
1676
- assert.throws(
1677
- () => new cf.shortcuts.hookshot.Github(),
1678
- /You must provide a Prefix, and PassthroughTo/,
1679
- 'throws without required parameters'
1680
- );
1453
+ describe('[shortcuts] hookshot github', () => {
1454
+ test('throws without required parameters', () => {
1455
+ expect(() => new cf.shortcuts.hookshot.Github()).toThrow(/You must provide a Prefix, and PassthroughTo/);
1456
+ });
1681
1457
 
1682
- assert.throws(
1683
- () =>
1684
- new cf.shortcuts.hookshot.Github({
1685
- Prefix: 'Pass',
1686
- PassthroughTo: 'Destination',
1687
- Runtime: 'python3.7'
1688
- }),
1689
- /Only valid nodejs runtimes are supported for hookshot lambdas, received: 'python3.7'/,
1690
- 'throws with invalid lambda Runtime python3.7'
1691
- );
1458
+ test('throws with invalid lambda Runtime python3.7', () => {
1459
+ expect(() => new cf.shortcuts.hookshot.Github({
1460
+ Prefix: 'Pass',
1461
+ PassthroughTo: 'Destination',
1462
+ Runtime: 'python3.7'
1463
+ })).toThrow(/Only valid nodejs runtimes are supported for hookshot lambdas, received: 'python3.7'/);
1464
+ });
1692
1465
 
1693
- assert.throws(
1694
- () =>
1695
- new cf.shortcuts.hookshot.Github({
1696
- Prefix: 'Pass',
1697
- PassthroughTo: 'Destination',
1698
- Runtime: 'nodejs16.x'
1699
- }),
1700
- /Only nodejs runtimes >= 18 are supported for hookshot lambdas, received: 'nodejs16.x'/,
1701
- 'throws with invalid lambda Runtime nodejs16.x'
1702
- );
1466
+ test('throws with invalid lambda Runtime nodejs16.x', () => {
1467
+ expect(() => new cf.shortcuts.hookshot.Github({
1468
+ Prefix: 'Pass',
1469
+ PassthroughTo: 'Destination',
1470
+ Runtime: 'nodejs16.x'
1471
+ })).toThrow(/Only nodejs runtimes >= 18 are supported for hookshot lambdas, received: 'nodejs16.x'/);
1472
+ });
1703
1473
 
1704
- const to = new cf.shortcuts.Lambda({
1474
+ const getDestinationLambda = () => new cf.shortcuts.Lambda({
1705
1475
  LogicalName: 'Destination',
1706
1476
  Code: {
1707
1477
  ZipFile: 'module.exports.handler = (e, c, cb) => cb();'
1708
1478
  }
1709
1479
  });
1710
1480
 
1711
- let github = new cf.shortcuts.hookshot.Github({
1712
- Prefix: 'Pass',
1713
- PassthroughTo: 'Destination'
1714
- });
1715
-
1716
- let template = cf.merge(github, to);
1717
- if (update) fixtures.update('hookshot-github', template);
1718
- assert.deepEqual(
1719
- normalizeDeployment(noUndefined(template)),
1720
- normalizeDeployment(fixtures.get('hookshot-github')),
1721
- 'expected resources generated with defaults'
1722
- );
1481
+ test('expected resources generated with defaults', () => {
1482
+ const to = getDestinationLambda();
1483
+ const github = new cf.shortcuts.hookshot.Github({
1484
+ Prefix: 'Pass',
1485
+ PassthroughTo: 'Destination'
1486
+ });
1723
1487
 
1724
- github = new cf.shortcuts.hookshot.Github({
1725
- Prefix: 'Pass',
1726
- PassthroughTo: 'Destination',
1727
- WebhookSecret: 'abc123'
1488
+ const template = cf.merge(github, to);
1489
+ if (update) fixtures.update('hookshot-github', template);
1490
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-github')));
1728
1491
  });
1729
1492
 
1730
- template = cf.merge(github, to);
1731
- if (update) fixtures.update('hookshot-github-secret-string', template);
1732
- assert.deepEqual(
1733
- normalizeDeployment(noUndefined(template)),
1734
- normalizeDeployment(fixtures.get('hookshot-github-secret-string')),
1735
- 'expected resources generated when secret passed as string'
1736
- );
1493
+ test('expected resources generated when secret passed as string', () => {
1494
+ const to = getDestinationLambda();
1495
+ const github = new cf.shortcuts.hookshot.Github({
1496
+ Prefix: 'Pass',
1497
+ PassthroughTo: 'Destination',
1498
+ WebhookSecret: 'abc123'
1499
+ });
1737
1500
 
1738
- github = new cf.shortcuts.hookshot.Github({
1739
- Prefix: 'Pass',
1740
- PassthroughTo: 'Destination',
1741
- WebhookSecret: cf.ref('SomeParameter')
1742
- });
1743
- const Parameters = { SomeParameter: { Type: 'String' } };
1744
- template = cf.merge(github, to, { Parameters });
1745
- if (update) fixtures.update('hookshot-github-secret-ref', template);
1746
- assert.deepEqual(
1747
- normalizeDeployment(noUndefined(template)),
1748
- normalizeDeployment(fixtures.get('hookshot-github-secret-ref')),
1749
- 'expected resources generated when secret passed as ref'
1750
- );
1501
+ const template = cf.merge(github, to);
1502
+ if (update) fixtures.update('hookshot-github-secret-string', template);
1503
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-github-secret-string')));
1504
+ });
1751
1505
 
1752
- assert.end();
1506
+ test('expected resources generated when secret passed as ref', () => {
1507
+ const to = getDestinationLambda();
1508
+ const github = new cf.shortcuts.hookshot.Github({
1509
+ Prefix: 'Pass',
1510
+ PassthroughTo: 'Destination',
1511
+ WebhookSecret: cf.ref('SomeParameter')
1512
+ });
1513
+ const Parameters = { SomeParameter: { Type: 'String' } };
1514
+ const template = cf.merge(github, to, { Parameters });
1515
+ if (update) fixtures.update('hookshot-github-secret-ref', template);
1516
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-github-secret-ref')));
1517
+ });
1753
1518
  });