Skip to content

Commit

Permalink
Merge branch 'main' into rds/add-aurora-postgresql-15-3
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jul 17, 2023
2 parents c4b8441 + ad39ffc commit f7fd03c
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 43 deletions.
1 change: 1 addition & 0 deletions packages/aws-cdk-lib/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ coverage
# Build gear
build-tools
dist
!custom-resource-handlers/dist/
scripts
.LAST_BUILD
.LAST_PACKAGE
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export class Bundling implements cdk.BundlingOptions {
osCommand.copy(lockFilePath, pathJoin(options.outputDir, this.packageManager.lockFile)),
osCommand.changeDirectory(options.outputDir),
this.packageManager.installCommand.join(' '),
isPnpm ? osCommand.remove(pathJoin(options.outputDir, 'node_modules', '.modules.yaml')) : '', // Remove '.modules.yaml' file which changes on each deployment
isPnpm ? osCommand.remove(pathJoin(options.outputDir, 'node_modules', '.modules.yaml')) + ' -f' : '', // Remove '.modules.yaml' file which changes on each deployment
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ test('Detects pnpm-lock.yaml', () => {
assetHashType: AssetHashType.OUTPUT,
bundling: expect.objectContaining({
command: expect.arrayContaining([
expect.stringMatching(/echo '' > "\/asset-output\/pnpm-workspace.yaml\".+pnpm-lock\.yaml.+pnpm install --config.node-linker=hoisted --config.package-import-method=clone-or-copy --no-prefer-frozen-lockfile && rm "\/asset-output\/node_modules\/.modules.yaml"/),
expect.stringMatching(/echo '' > "\/asset-output\/pnpm-workspace.yaml\".+pnpm-lock\.yaml.+pnpm install --config.node-linker=hoisted --config.package-import-method=clone-or-copy --no-prefer-frozen-lockfile && rm "\/asset-output\/node_modules\/.modules.yaml" -f/),
]),
}),
});
Expand Down
42 changes: 21 additions & 21 deletions packages/aws-cdk-lib/aws-lambda-nodejs/test/function.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ beforeEach(() => {
jest.clearAllMocks();
});

test.skip('NodejsFunction with .ts handler', () => {
test('NodejsFunction with .ts handler', () => {
// WHEN
new NodejsFunction(stack, 'handler1');

Expand All @@ -41,11 +41,11 @@ test.skip('NodejsFunction with .ts handler', () => {

Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Function', {
Handler: 'index.handler',
Runtime: 'nodejs14.x',
Runtime: Match.stringLikeRegexp('nodejs'),
});
});

test.skip('NodejsFunction with overridden handler - no dots', () => {
test('NodejsFunction with overridden handler - no dots', () => {
// WHEN
new NodejsFunction(stack, 'handler1', {
handler: 'myHandler',
Expand All @@ -57,11 +57,11 @@ test.skip('NodejsFunction with overridden handler - no dots', () => {

Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Function', {
Handler: 'index.myHandler', // automatic index. prefix
Runtime: 'nodejs14.x',
Runtime: Match.stringLikeRegexp('nodejs'),
});
});

test.skip('NodejsFunction with overridden handler - with dots', () => {
test('NodejsFunction with overridden handler - with dots', () => {
// WHEN
new NodejsFunction(stack, 'handler1', {
handler: 'run.sh',
Expand All @@ -73,11 +73,11 @@ test.skip('NodejsFunction with overridden handler - with dots', () => {

Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Function', {
Handler: 'run.sh', // No index. prefix
Runtime: 'nodejs14.x',
Runtime: Match.stringLikeRegexp('nodejs'),
});
});

test.skip('NodejsFunction with .js handler', () => {
test('NodejsFunction with .js handler', () => {
// WHEN
new NodejsFunction(stack, 'handler2');

Expand All @@ -87,7 +87,7 @@ test.skip('NodejsFunction with .js handler', () => {
}));
});

test.skip('NodejsFunction with .mjs handler', () => {
test('NodejsFunction with .mjs handler', () => {
// WHEN
new NodejsFunction(stack, 'handler3');

Expand Down Expand Up @@ -144,13 +144,13 @@ test('NodejsFunction with container env vars', () => {
}));
});

test.skip('throws when entry is not js/ts', () => {
test('throws when entry is not js/ts', () => {
expect(() => new NodejsFunction(stack, 'Fn', {
entry: 'handler.py',
})).toThrow(/Only JavaScript or TypeScript entry files are supported/);
});

test.skip('accepts tsx', () => {
test('accepts tsx', () => {
const entry = path.join(__dirname, 'handler.tsx');

fs.symlinkSync(path.join(__dirname, 'function.test.handler1.ts'), entry);
Expand All @@ -162,35 +162,35 @@ test.skip('accepts tsx', () => {
fs.unlinkSync(entry);
});

test.skip('throws when entry does not exist', () => {
test('throws when entry does not exist', () => {
expect(() => new NodejsFunction(stack, 'Fn', {
entry: 'notfound.ts',
})).toThrow(/Cannot find entry file at/);
});

test.skip('throws when entry cannot be automatically found', () => {
expect(() => new NodejsFunction(stack, 'Fn')).toThrow(/Cannot find handler file .*function.test.Fn.ts, .*function.test.Fn.js or .*function.test.Fn.mjs/);
test('throws when entry cannot be automatically found', () => {
expect(() => new NodejsFunction(stack, 'Fn')).toThrow(/Cannot find handler file .*function\.test\.Fn\.ts.*function\.test\.Fn\.js.*function\.test\.Fn\.mjs/);
});

test.skip('throws with the wrong runtime family', () => {
test('throws with the wrong runtime family', () => {
expect(() => new NodejsFunction(stack, 'handler1', {
runtime: Runtime.PYTHON_3_8,
})).toThrow(/Only `NODEJS` runtimes are supported/);
});

test.skip('throws with non existing lock file', () => {
test('throws with non existing lock file', () => {
expect(() => new NodejsFunction(stack, 'handler1', {
depsLockFilePath: '/does/not/exist.lock',
})).toThrow(/Lock file at \/does\/not\/exist.lock doesn't exist/);
});

test.skip('throws when depsLockFilePath is not a file', () => {
test('throws when depsLockFilePath is not a file', () => {
expect(() => new NodejsFunction(stack, 'handler1', {
depsLockFilePath: __dirname,
})).toThrow(/\`depsLockFilePath\` should point to a file/);
});

test.skip('resolves depsLockFilePath to an absolute path', () => {
test('resolves depsLockFilePath to an absolute path', () => {
new NodejsFunction(stack, 'handler1', {
depsLockFilePath: './package.json',
});
Expand All @@ -200,7 +200,7 @@ test.skip('resolves depsLockFilePath to an absolute path', () => {
}));
});

test.skip('resolves entry to an absolute path', () => {
test('resolves entry to an absolute path', () => {
// WHEN
new NodejsFunction(stack, 'fn', {
entry: 'aws-lambda-nodejs/lib/index.ts',
Expand All @@ -211,7 +211,7 @@ test.skip('resolves entry to an absolute path', () => {
}));
});

test.skip('configures connection reuse for aws sdk', () => {
test('configures connection reuse for aws sdk', () => {
// WHEN
new NodejsFunction(stack, 'handler1');

Expand All @@ -224,7 +224,7 @@ test.skip('configures connection reuse for aws sdk', () => {
});
});

test.skip('can opt-out of connection reuse for aws sdk', () => {
test('can opt-out of connection reuse for aws sdk', () => {
// WHEN
new NodejsFunction(stack, 'handler1', {
awsSdkConnectionReuse: false,
Expand All @@ -235,7 +235,7 @@ test.skip('can opt-out of connection reuse for aws sdk', () => {
});
});

test.skip('NodejsFunction in a VPC', () => {
test('NodejsFunction in a VPC', () => {
// GIVEN
const vpc = new Vpc(stack, 'Vpc');

Expand Down
38 changes: 19 additions & 19 deletions packages/aws-cdk-lib/aws-lambda-nodejs/test/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,72 +12,72 @@ describe('callsites', () => {
});

describe('findUp', () => {
test.skip('Starting at process.cwd()', () => {
test('Starting at process.cwd()', () => {
expect(findUp('README.md')).toMatch(/aws-cdk-lib\/README.md$/);
});

test.skip('Non existing file', () => {
test('Non existing file', () => {
expect(findUp('non-existing-file.unknown')).toBe(undefined);
});

test.skip('Starting at a specific path', () => {
test('Starting at a specific path', () => {
expect(findUp('util.test.ts', path.join(__dirname, 'integ-handlers'))).toMatch(/aws-lambda-nodejs\/test\/util.test.ts$/);
});

test.skip('Non existing file starting at a non existing relative path', () => {
test('Non existing file starting at a non existing relative path', () => {
expect(findUp('not-to-be-found.txt', 'non-existing/relative/path')).toBe(undefined);
});

test.skip('Starting at a relative path', () => {
test('Starting at a relative path', () => {
expect(findUp('util.test.ts', 'aws-lambda-nodejs/test/integ-handlers')).toMatch(/aws-lambda-nodejs\/test\/util.test.ts$/);
});
});

describe('findUpMultiple', () => {
test.skip('Starting at process.cwd()', () => {
test('Starting at process.cwd()', () => {
const files = findUpMultiple(['README.md', 'package.json']);
expect(files).toHaveLength(2);
expect(files[0]).toMatch(/aws-cdk-lib\/README\.md$/);
expect(files[1]).toMatch(/aws-cdk-lib\/package\.json$/);
});

test.skip('Non existing files', () => {
test('Non existing files', () => {
expect(findUpMultiple(['non-existing-file.unknown', 'non-existing-file.unknown2'])).toEqual([]);
});

test.skip('Existing and non existing files', () => {
test('Existing and non existing files', () => {
const files = findUpMultiple(['non-existing-file.unknown', 'README.md']);
expect(files).toHaveLength(1);
expect(files[0]).toMatch(/aws-cdk-lib\/README\.md$/);
});

test.skip('Starting at a specific path', () => {
test('Starting at a specific path', () => {
const files = findUpMultiple(['util.test.ts', 'function.test.ts'], path.join(__dirname, 'integ-handlers'));
expect(files).toHaveLength(2);
expect(files[0]).toMatch(/aws-lambda-nodejs\/test\/util\.test\.ts$/);
expect(files[1]).toMatch(/aws-lambda-nodejs\/test\/function\.test\.ts$/);
});

test.skip('Non existing files starting at a non existing relative path', () => {
test('Non existing files starting at a non existing relative path', () => {
expect(findUpMultiple(['not-to-be-found.txt', 'not-to-be-found2.txt'], 'non-existing/relative/path')).toEqual([]);
});

test.skip('Starting at a relative path', () => {
test('Starting at a relative path', () => {
const files = findUpMultiple(['util.test.ts', 'function.test.ts'], 'aws-lambda-nodejs/test/integ-handlers');
expect(files).toHaveLength(2);
expect(files[0]).toMatch(/aws-lambda-nodejs\/test\/util\.test\.ts$/);
expect(files[1]).toMatch(/aws-lambda-nodejs\/test\/function\.test\.ts$/);
});

test.skip('Files on multiple levels', () => {
test('Files on multiple levels', () => {
const files = findUpMultiple(['README.md', 'util.test.ts'], path.join(__dirname, 'integ-handlers'));
expect(files).toHaveLength(1);
expect(files[0]).toMatch(/aws-lambda-nodejs\/test\/util\.test\.ts$/);
});
});

describe('exec', () => {
test.skip('normal execution', () => {
test('normal execution', () => {
const spawnSyncMock = jest.spyOn(child_process, 'spawnSync').mockReturnValue({
status: 0,
stderr: Buffer.from('stderr'),
Expand All @@ -103,7 +103,7 @@ describe('exec', () => {
spawnSyncMock.mockRestore();
});

test.skip('non zero status', () => {
test('non zero status', () => {
const spawnSyncMock = jest.spyOn(child_process, 'spawnSync').mockReturnValue({
status: 999,
stderr: Buffer.from('error occured'),
Expand All @@ -118,7 +118,7 @@ describe('exec', () => {
spawnSyncMock.mockRestore();
});

test.skip('with error', () => {
test('with error', () => {
const spawnSyncMock = jest.spyOn(child_process, 'spawnSync').mockReturnValue({
error: new Error('bad error'),
status: 0,
Expand All @@ -136,7 +136,7 @@ describe('exec', () => {
});

describe('extractDependencies', () => {
test.skip('with dependencies referenced in package.json', () => {
test('with dependencies referenced in package.json', () => {
const deps = extractDependencies(
path.join(__dirname, 'testpackage.json'),
['@aws-cdk/aws-lambda', '@aws-cdk/core'],
Expand All @@ -147,7 +147,7 @@ describe('extractDependencies', () => {
]);
});

test.skip('with transitive dependencies', () => {
test('with transitive dependencies', () => {
expect(extractDependencies(
path.join(__dirname, 'testpackage.json'),
['typescript'],
Expand All @@ -157,14 +157,14 @@ describe('extractDependencies', () => {
});
});

test.skip('with unknown dependency', () => {
test('with unknown dependency', () => {
expect(() => extractDependencies(
path.join(__dirname, 'testpackage.json'),
['unknown'],
)).toThrow(/Cannot extract version for module 'unknown'/);
});

test.skip('with file dependency', () => {
test('with file dependency', () => {
const pkgPath = path.join(__dirname, 'package-file.json');
fs.writeFileSync(pkgPath, JSON.stringify({
dependencies: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { generateSchema, SCHEMAS } from '../scripts/update-schema';

test.skip('if this test fails, run "yarn update-schema"', () => {
test('if this test fails, run "yarn update-schema"', () => {

// when we compare schemas we ignore changes the
// description that is generated from the ts docstrings.
Expand Down
2 changes: 2 additions & 0 deletions tools/@aws-cdk/cdk-build-tools/config/eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,5 +214,7 @@ module.exports = {
"jest/valid-expect": "off", // expect from '@aws-cdk/assert' can take a second argument
"jest/valid-title": "off", // A little over-zealous with test('test foo') being an error.
"jest/no-identical-title": "off", // TEMPORARY - Disabling this until https://github.com/jest-community/eslint-plugin-jest/issues/836 is resolved
'jest/no-disabled-tests': 'error', // Skipped tests are easily missed in PR reviews
'jest/no-focused-tests': 'error', // Focused tests are easily missed in PR reviews
},
};

0 comments on commit f7fd03c

Please sign in to comment.