Skip to content

Commit a279b98

Browse files
authored
chore: add Amplify integration tests (#31921)
Test integration with the Amplify client, that uses CDK under the hood. Creates a new project, deploys it, and then deletes it again. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent d108a80 commit a279b98

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

packages/@aws-cdk-testing/cli-integ/lib/package-sources/release-source.ts

+4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ export class ReleasePackageSource implements IPackageSource {
6060
return this.version.split('.')[0] as string;
6161
}
6262

63+
public requestedCliVersion() {
64+
return this.version;
65+
}
66+
6367
public requestedFrameworkVersion() {
6468
return process.env.FRAMEWORK_VERSION!;
6569
}

packages/@aws-cdk-testing/cli-integ/lib/package-sources/repo-source.ts

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ export class RepoPackageSource implements IPackageSource {
4949
return releaseJson.majorVersion;
5050
}
5151

52+
public requestedCliVersion(): string {
53+
return '*';
54+
}
55+
5256
public requestedFrameworkVersion(): string {
5357
return '*';
5458
}

packages/@aws-cdk-testing/cli-integ/lib/package-sources/source.ts

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export interface IPackageSource {
1414

1515
initializeDotnetPackages(targetDir: string): Promise<void>;
1616

17+
/**
18+
* CLI version
19+
*/
20+
requestedCliVersion(): string;
21+
1722
/**
1823
* Framework version if it's different than the CLI version
1924
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { promises as fs } from 'fs';
2+
import * as path from 'path';
3+
import { integTest, withTemporaryDirectory, ShellHelper, withPackages, TemporaryDirectoryContext } from '../../lib';
4+
5+
const TIMEOUT = 1800_000;
6+
7+
integTest('amplify integration', withTemporaryDirectory(withPackages(async (context) => {
8+
const shell = ShellHelper.fromContext(context);
9+
10+
await shell.shell(['npm', 'create', '-y', 'amplify@latest']);
11+
await shell.shell(['npx', 'ampx', 'configure', 'telemetry', 'disable']);
12+
13+
// This will create 'package.json' implicating a certain version of the CDK
14+
await updateCdkDependency(context, context.packages.requestedCliVersion(), context.packages.requestedFrameworkVersion());
15+
await shell.shell(['npm', 'install']);
16+
17+
await shell.shell(['npx', 'ampx', 'sandbox', '--once']);
18+
await shell.shell(['npx', 'ampx', 'sandbox', 'delete', '--yes']);
19+
})), TIMEOUT);
20+
21+
async function updateCdkDependency(context: TemporaryDirectoryContext, cliVersion: string, libVersion: string) {
22+
const filename = path.join(context.integTestDir, 'package.json');
23+
const pj = JSON.parse(await fs.readFile(filename, { encoding: 'utf-8' }));
24+
pj.devDependencies['aws-cdk'] = cliVersion;
25+
pj.devDependencies['aws-cdk-lib'] = libVersion;
26+
await fs.writeFile(filename, JSON.stringify(pj, undefined, 2), { encoding: 'utf-8' });
27+
}

0 commit comments

Comments
 (0)