Skip to content

Commit

Permalink
add import test
Browse files Browse the repository at this point in the history
  • Loading branch information
comcalvi committed Mar 13, 2024
1 parent 6be7f06 commit 2c9dd9e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/aws-cdk/test/diff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,21 @@ import { Deployments } from '../lib/api/deployments';
import { CdkToolkit } from '../lib/cdk-toolkit';
import * as cfn from '../lib/api/util/cloudformation';
import { NestedStackTemplates } from '../lib/api/nested-stack-helpers';
import * as fs from 'fs';

let cloudExecutable: MockCloudExecutable;
let cloudFormation: jest.Mocked<Deployments>;
let toolkit: CdkToolkit;

describe('imports', () => {
beforeEach(() => {
const outputToJson = {
'//': 'This file is generated by cdk migrate. It will be automatically deleted after the first successful deployment of this app to the environment of the original resources.',
'Source': 'localfile',
'Resources': [],
};
fs.writeFileSync('migrate.json', JSON.stringify(outputToJson, null, 2));

jest.spyOn(cfn, 'createDiffChangeSet').mockImplementationOnce(async () => {
return {
Changes: [
Expand Down Expand Up @@ -82,6 +90,10 @@ describe('imports', () => {
}));
});

afterEach(() => {
fs.rmSync('migrate.json');
});

test('imports', async () => {
// GIVEN
const buffer = new StringWritable();
Expand All @@ -96,6 +108,7 @@ describe('imports', () => {
// THEN
const plainTextOutput = buffer.data.replace(/\x1B\[[0-?]*[ -/]*[@-~]/g, '');
expect(plainTextOutput).toContain(`Stack A
Parameters and rules created during migration do not affect resource configuration.
Resources
[←] AWS::SQS::Queue Queue import
[←] AWS::SQS::Queue Queue2 import
Expand Down

0 comments on commit 2c9dd9e

Please sign in to comment.