-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { promises as fs } from 'fs'; | ||
import * as path from 'path'; | ||
import { withToolContext } from './with-tool-context'; | ||
import { integTest, ShellHelper, TemporaryDirectoryContext } from '../../lib'; | ||
|
||
const TIMEOUT = 1800_000; | ||
|
||
integTest('amplify integration', withToolContext(async (context) => { | ||
const shell = ShellHelper.fromContext(context); | ||
|
||
await shell.shell(['npm', 'create', '-y', 'amplify@latest']); | ||
await shell.shell(['npx', 'ampx', 'configure', 'telemetry', 'disable']); | ||
|
||
// This will create 'package.json' implicating a certain version of the CDK | ||
await updateCdkDependency(context, context.packages.requestedCliVersion(), context.packages.requestedFrameworkVersion()); | ||
await shell.shell(['npm', 'install']); | ||
|
||
await shell.shell(['npx', 'ampx', 'sandbox', '--once'], { | ||
modEnv: { | ||
AWS_REGION: context.aws.region, | ||
}, | ||
}); | ||
try { | ||
|
||
// Future code goes here, putting the try/finally here already so it doesn't | ||
// get forgotten. | ||
|
||
} finally { | ||
await shell.shell(['npx', 'ampx', 'sandbox', 'delete', '--yes'], { | ||
modEnv: { | ||
AWS_REGION: context.aws.region, | ||
}, | ||
}); | ||
} | ||
}), TIMEOUT); | ||
|
||
async function updateCdkDependency(context: TemporaryDirectoryContext, cliVersion: string, libVersion: string) { | ||
const filename = path.join(context.integTestDir, 'package.json'); | ||
const pj = JSON.parse(await fs.readFile(filename, { encoding: 'utf-8' })); | ||
pj.devDependencies['aws-cdk'] = cliVersion; | ||
pj.devDependencies['aws-cdk-lib'] = libVersion; | ||
await fs.writeFile(filename, JSON.stringify(pj, undefined, 2), { encoding: 'utf-8' }); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { TestContext } from '../../lib/integ-test'; | ||
import { AwsContext, withAws } from '../../lib/with-aws'; | ||
import { DisableBootstrapContext } from '../../lib/with-cdk-app'; | ||
import { PackageContext, withPackages } from '../../lib/with-packages'; | ||
import { TemporaryDirectoryContext, withTemporaryDirectory } from '../../lib/with-temporary-directory'; | ||
|
||
/** | ||
* The default prerequisites for tests running tool integrations | ||
*/ | ||
export function withToolContext<A extends TestContext>( | ||
block: (context: A & TemporaryDirectoryContext & PackageContext & AwsContext & DisableBootstrapContext | ||
) => Promise<void>) { | ||
return withAws(withTemporaryDirectory(withPackages(block))); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.