Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,8 @@ const cli = configureProject(
'@types/sinon',
'@types/yargs@^15',
'aws-cdk-lib',
'aws-sdk-client-mock',
'aws-sdk-client-mock-jest',
Comment on lines +1005 to +1006
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were missing dev deps that eslint discovered.

'axios',
'constructs',
'fast-check',
Expand Down Expand Up @@ -1097,7 +1099,7 @@ const cli = configureProject(
},
eslintOptions: {
dirs: ['lib'],
ignorePatterns: ['*.template.ts', '*.d.ts', 'test/**/*.ts'],
ignorePatterns: ['*.template.ts', '*.d.ts'],
},
jestOptions: jestOptionsForProject({
jestConfig: {
Expand Down Expand Up @@ -1144,6 +1146,7 @@ cli.eslint?.addOverride({
files: ['./test/**'],
rules: {
'@cdklabs/no-throw-default-error': 'off',
'@typescript-eslint/unbound-method': 'off',
},
});

Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk/.eslintrc.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions packages/aws-cdk/.projen/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/aws-cdk/.projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/aws-cdk/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions packages/aws-cdk/test/_helpers/assembly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import * as path from 'path';
import { ArtifactMetadataEntryType, ArtifactType, type AssetManifest, type AssetMetadataEntry, type AwsCloudFormationStackProperties, type MetadataEntry, type MissingContext } from '@aws-cdk/cloud-assembly-schema';
import { type CloudAssembly, CloudAssemblyBuilder, type CloudFormationStackArtifact, type StackMetadata } from '@aws-cdk/cx-api';
import { cxapiAssemblyWithForcedVersion } from './assembly-versions';
import { MockSdkProvider } from '../_helpers/mock-sdk';
import { CloudExecutable } from '../../lib/cxapp/cloud-executable';
import { Configuration } from '../../lib/cli/user-configuration';
import { TestIoHost } from './io-host';
import { IIoHost } from '../../lib/cli/io-host';
import { asIoHelper } from '../../../@aws-cdk/toolkit-lib/lib/api/io/private';
import type { IIoHost } from '../../lib/cli/io-host';
import { Configuration } from '../../lib/cli/user-configuration';
import { CloudExecutable } from '../../lib/cxapp/cloud-executable';
import { MockSdkProvider } from '../_helpers/mock-sdk';

export const DEFAULT_FAKE_TEMPLATE = { No: 'Resources' };

Expand Down Expand Up @@ -47,7 +47,7 @@ export class MockCloudExecutable extends CloudExecutable {
const configuration = new Configuration();
const sdkProvider = sdkProviderArg ?? new MockSdkProvider();
const mockIoHost = ioHost ?? new TestIoHost();

super({
configuration,
sdkProvider,
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/test/_helpers/fake-io-host.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IIoHost, IoMessage, IoMessageLevel, IoRequest } from "../../../@aws-cdk/toolkit-lib/lib/api/io";
import type { IIoHost, IoMessage, IoMessageLevel, IoRequest } from '../../../@aws-cdk/toolkit-lib/lib/api/io';

/**
* An implementation of `IIoHost` that records messages and lets you assert on what was logged
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/test/_helpers/jest-bufferedconsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* A Jest environment that buffers outputs to `console.log()` and only shows it for failing tests.
*/
import type { EnvironmentContext, JestEnvironment, JestEnvironmentConfig } from '@jest/environment';
import { Circus } from '@jest/types';
import type { Circus } from '@jest/types';
import { TestEnvironment as NodeEnvironment } from 'jest-environment-node';

interface ConsoleMessage {
Expand Down
4 changes: 3 additions & 1 deletion packages/aws-cdk/test/_helpers/jest-setup-after-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ afterAll(async () => {
await new Promise<void>((resolve, reject) => {
const response = aft(resolve as any);
if (isPromise(response)) {
response.then(() => { return resolve(); }, reject);
response.then(() => {
return resolve();
}, reject);
} else {
resolve();
}
Expand Down
11 changes: 6 additions & 5 deletions packages/aws-cdk/test/_helpers/mock-sdk.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'aws-sdk-client-mock-jest';
import { Environment } from '@aws-cdk/cx-api';
import type { Environment } from '@aws-cdk/cx-api';
import { AppSyncClient } from '@aws-sdk/client-appsync';
import { CloudControlClient } from '@aws-sdk/client-cloudcontrol';
import { CloudFormationClient, Stack, StackStatus } from '@aws-sdk/client-cloudformation';
import type { Stack } from '@aws-sdk/client-cloudformation';
import { CloudFormationClient, StackStatus } from '@aws-sdk/client-cloudformation';
import { CloudWatchLogsClient } from '@aws-sdk/client-cloudwatch-logs';
import { CodeBuildClient } from '@aws-sdk/client-codebuild';
import { EC2Client } from '@aws-sdk/client-ec2';
Expand All @@ -19,12 +20,12 @@ import { SFNClient } from '@aws-sdk/client-sfn';
import { SSMClient } from '@aws-sdk/client-ssm';
import { AssumeRoleCommand, GetCallerIdentityCommand, STSClient } from '@aws-sdk/client-sts';
import { createCredentialChain } from '@aws-sdk/credential-providers';
import { AwsCredentialIdentity } from '@smithy/types';
import type { AwsCredentialIdentity } from '@smithy/types';
import { mockClient } from 'aws-sdk-client-mock';
import { type Account } from 'cdk-assets';
import { TestIoHost } from './io-host';
import { SDK, SdkProvider } from '../../lib/api/aws-auth';
import { CloudFormationStack } from '../../lib/api/cloudformation';
import { TestIoHost } from './io-host';

export const FAKE_CREDENTIALS: AwsCredentialIdentity = {
accessKeyId: 'ACCESS',
Expand Down Expand Up @@ -98,7 +99,7 @@ export const restoreSdkMocksToDefault = () => {
*/
export function undoAllSdkMocks() {
applyToAllMocks('restore');
};
}

function applyToAllMocks(meth: 'reset' | 'restore') {
mockAppSyncClient[meth]();
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/test/_helpers/mock-toolkitinfo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable import/order */
import { ToolkitInfo, DEFAULT_BOOTSTRAP_VARIANT } from '../../lib/api';
import { CloudFormationStack } from '../../lib/api/cloudformation';
import type { CloudFormationStack } from '../../lib/api/cloudformation';

export interface MockToolkitInfoProps {
readonly bucketName?: string;
Expand Down
36 changes: 19 additions & 17 deletions packages/aws-cdk/test/cli/cdk-toolkit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const fakeChokidarWatcherOn = {
},

get fileEventCallback(): (
event: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir',
path: string,
event: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir',
path: string,
) => Promise<void> {
expect(mockChokidarWatcherOn.mock.calls.length).toBeGreaterThanOrEqual(2);
const secondCall = mockChokidarWatcherOn.mock.calls[1];
Expand Down Expand Up @@ -60,46 +60,49 @@ jest.setTimeout(30_000);
import 'aws-sdk-client-mock';
import * as os from 'os';
import * as path from 'path';
import * as cdkAssets from 'cdk-assets';
import * as cxschema from '@aws-cdk/cloud-assembly-schema';
import { Manifest } from '@aws-cdk/cloud-assembly-schema';
import * as cxapi from '@aws-cdk/cx-api';
import type { DestroyStackResult } from '@aws-cdk/toolkit-lib/lib/api/deployments/deploy-stack';
import { DescribeStacksCommand, GetTemplateCommand, StackStatus } from '@aws-sdk/client-cloudformation';
import { GetParameterCommand } from '@aws-sdk/client-ssm';
import * as cdkAssets from 'cdk-assets';
import * as fs from 'fs-extra';
import * as promptly from 'promptly';
import { SdkProvider } from '../../lib/api';
import type { Template } from '../../../@aws-cdk/toolkit-lib/lib/api';
import { asIoHelper } from '../../../@aws-cdk/toolkit-lib/lib/api/io/private';
import type { SdkProvider } from '../../lib/api';
import { Bootstrapper, type BootstrapSource } from '../../lib/api/bootstrap';
import {
import type {
DeployStackResult,
SuccessfulDeployStackResult,
Deployments,
DeployStackOptions,
DestroyStackOptions,
RollbackStackOptions,
RollbackStackResult,
} from '../../lib/api/deployments';
import {
Deployments,
} from '../../lib/api/deployments';
import { HotswapMode } from '../../lib/api/hotswap';
import { Mode } from '../../lib/api/plugin';
import { Tag } from '../../lib/api/tags';
import type { Tag } from '../../lib/api/tags';
import { CdkToolkit, markTesting } from '../../lib/cli/cdk-toolkit';
import { CliIoHost } from '../../lib/cli/io-host';
import { Configuration } from '../../lib/cli/user-configuration';
import { StackActivityProgress } from '../../lib/commands/deploy';
import { RequireApproval } from '../../lib/commands/diff';
import { CliIoHost } from '../../lib/cli/io-host';
import { flatten } from '../../lib/util';
import { MockCloudExecutable, TestStackArtifact } from '../_helpers/assembly';
import { instanceMockFrom } from '../_helpers/as-mock';
import type { TestStackArtifact } from '../_helpers/assembly';
import { MockCloudExecutable } from '../_helpers/assembly';
import {
mockCloudFormationClient,
MockSdk,
MockSdkProvider,
mockSSMClient,
restoreSdkMocksToDefault,
} from '../_helpers/mock-sdk';
import { asIoHelper } from '../../../@aws-cdk/toolkit-lib/lib/api/io/private';
import { StackActivityProgress } from '../../lib/commands/deploy';
import { Template } from '../../../@aws-cdk/toolkit-lib/lib/api';
import { DestroyStackResult } from '@aws-cdk/toolkit-lib/lib/api/deployments/deploy-stack';

markTesting();

Expand Down Expand Up @@ -154,7 +157,6 @@ function defaultToolkitSetup() {

const mockSdk = new MockSdk();


describe('bootstrap', () => {
test('accepts qualifier from context', async () => {
// GIVEN
Expand Down Expand Up @@ -276,6 +278,7 @@ describe('deploy', () => {
deployments: new FakeCloudFormation({}),
});
stderrMock.mockImplementation((...x) => {
// eslint-disable-next-line no-console
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allow in this case

console.error(...x);
});

Expand Down Expand Up @@ -1034,8 +1037,8 @@ describe('deploy', () => {

await toolkit.deploy({
progress: StackActivityProgress.EVENTS,
selector: { patterns: ["**"] },
hotswap: HotswapMode.FALL_BACK
selector: { patterns: ['**'] },
hotswap: HotswapMode.FALL_BACK,
});

// now expect it to be updated
Expand Down Expand Up @@ -1556,7 +1559,6 @@ describe('migrate', () => {
});

describe('rollback', () => {

test('rollback uses deployment role', async () => {
cloudExecutable = new MockCloudExecutable({
stacks: [MockStack.MOCK_STACK_C],
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/test/cli/cli-commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('doctor', () => {
await exec(['doctor']);
expect(logging.info).toHaveBeenCalledWith(expect.stringContaining('CDK Version:'));
});
})
});

describe('docs', () => {
test('prints docs url version', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { debug, error, info, success, warning } from '../../../lib/logging';
import { CliIoHost } from '../../../lib/cli/io-host';
import { debug, error, info, success, warning } from '../../../lib/logging';

const ioHost = CliIoHost.instance({}, true);
let mockStderr: jest.Mock;
Expand Down
7 changes: 4 additions & 3 deletions packages/aws-cdk/test/cli/io-host/cli-io-host.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { PassThrough } from 'stream';
import * as chalk from 'chalk';
import { CliIoHost, IoMessage, IoMessageLevel, IoRequest } from '../../../lib/cli/io-host';
import { RequireApproval } from '@aws-cdk/cloud-assembly-schema';
import * as chalk from 'chalk';
import type { IoMessage, IoMessageLevel, IoRequest } from '../../../lib/cli/io-host';
import { CliIoHost } from '../../../lib/cli/io-host';

let passThrough: PassThrough;

Expand Down Expand Up @@ -429,7 +430,7 @@ describe('CliIoHost', () => {
});

test('require approval by default - respond no', async () => {
expect(() => requestResponse('n', plainMessage({
await expect(() => requestResponse('n', plainMessage({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was missing before, all promises must be awaited

time: new Date(),
level: 'info',
action: 'synth',
Expand Down
Loading
Loading