|
1 | 1 | import { Lambda, StepFunctions } from 'aws-sdk';
|
| 2 | +import { CfnEvaluationException } from '../../../lib/api/evaluate-cloudformation-template'; |
2 | 3 | import * as setup from './hotswap-test-setup';
|
3 | 4 |
|
4 | 5 | let hotswapMockSdkProvider: setup.HotswapMockSdkProvider;
|
@@ -414,3 +415,89 @@ test('A change to both a hotswappable resource and a stack output results in a f
|
414 | 415 | expect(mockUpdateMachineDefinition).not.toHaveBeenCalled();
|
415 | 416 | expect(mockUpdateLambdaCode).not.toHaveBeenCalled();
|
416 | 417 | });
|
| 418 | + |
| 419 | +test('Multiple CfnEvaluationException will not cause unhandled rejections', async () => { |
| 420 | + // GIVEN |
| 421 | + setup.setCurrentCfnStackTemplate({ |
| 422 | + Resources: { |
| 423 | + Func1: { |
| 424 | + Type: 'AWS::Lambda::Function', |
| 425 | + Properties: { |
| 426 | + Code: { |
| 427 | + S3Bucket: 'current-bucket', |
| 428 | + S3Key: 'current-key', |
| 429 | + }, |
| 430 | + Environment: { |
| 431 | + key: 'old', |
| 432 | + }, |
| 433 | + FunctionName: 'my-function', |
| 434 | + }, |
| 435 | + Metadata: { |
| 436 | + 'aws:asset:path': 'old-path', |
| 437 | + }, |
| 438 | + }, |
| 439 | + Func2: { |
| 440 | + Type: 'AWS::Lambda::Function', |
| 441 | + Properties: { |
| 442 | + Code: { |
| 443 | + S3Bucket: 'current-bucket', |
| 444 | + S3Key: 'current-key', |
| 445 | + }, |
| 446 | + Environment: { |
| 447 | + key: 'old', |
| 448 | + }, |
| 449 | + FunctionName: 'my-function', |
| 450 | + }, |
| 451 | + Metadata: { |
| 452 | + 'aws:asset:path': 'old-path', |
| 453 | + }, |
| 454 | + }, |
| 455 | + }, |
| 456 | + }); |
| 457 | + const cdkStackArtifact = setup.cdkStackArtifactOf({ |
| 458 | + template: { |
| 459 | + Resources: { |
| 460 | + Func1: { |
| 461 | + Type: 'AWS::Lambda::Function', |
| 462 | + Properties: { |
| 463 | + Code: { |
| 464 | + S3Bucket: 'current-bucket', |
| 465 | + S3Key: 'current-key', |
| 466 | + }, |
| 467 | + Environment: { |
| 468 | + key: { Ref: 'ErrorResource' }, |
| 469 | + }, |
| 470 | + FunctionName: 'my-function', |
| 471 | + }, |
| 472 | + Metadata: { |
| 473 | + 'aws:asset:path': 'new-path', |
| 474 | + }, |
| 475 | + }, |
| 476 | + Func2: { |
| 477 | + Type: 'AWS::Lambda::Function', |
| 478 | + Properties: { |
| 479 | + Code: { |
| 480 | + S3Bucket: 'current-bucket', |
| 481 | + S3Key: 'current-key', |
| 482 | + }, |
| 483 | + Environment: { |
| 484 | + key: { Ref: 'ErrorResource' }, |
| 485 | + }, |
| 486 | + FunctionName: 'my-function', |
| 487 | + }, |
| 488 | + Metadata: { |
| 489 | + 'aws:asset:path': 'new-path', |
| 490 | + }, |
| 491 | + }, |
| 492 | + }, |
| 493 | + }, |
| 494 | + }); |
| 495 | + |
| 496 | + // WHEN |
| 497 | + const deployStackResult = hotswapMockSdkProvider.tryHotswapDeployment(cdkStackArtifact); |
| 498 | + |
| 499 | + // THEN |
| 500 | + await expect(deployStackResult).rejects.toThrowError(CfnEvaluationException); |
| 501 | + expect(mockUpdateMachineDefinition).not.toHaveBeenCalled(); |
| 502 | + expect(mockUpdateLambdaCode).not.toHaveBeenCalled(); |
| 503 | +}); |
0 commit comments