Skip to content

Commit

Permalink
chore(pipelines): test to make sure environment variables behave sanely
Browse files Browse the repository at this point in the history
Make sure that environment variables combine correctly and a BuildSpec
is still rendered.

Relates to #11877.
  • Loading branch information
rix0rrr committed Dec 7, 2020
1 parent 60875a5 commit 41bf349
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions packages/@aws-cdk/pipelines/test/builds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,63 @@ test.each([['npm'], ['yarn']])('%s assumes no build step by default', (npmYarn)
});
});

test('complex setup with environemnt variables still renders correct project', () => {
// WHEN
new TestGitHubNpmPipeline(pipelineStack, 'Cdk', {
sourceArtifact,
cloudAssemblyArtifact,
synthAction: new cdkp.SimpleSynthAction({
sourceArtifact,
cloudAssemblyArtifact,
environmentVariables: {
SOME_ENV_VAR: { value: 'SomeValue' },
},
environment: {
environmentVariables: {
INNER_VAR: { value: 'InnerValue' },
},
privileged: true,
},
installCommands: [
'install1',
'install2',
],
synthCommand: 'synth',
}),
});

// THEN
expect(pipelineStack).toHaveResourceLike('AWS::CodeBuild::Project', {
Environment: objectLike({
PrivilegedMode: true,
EnvironmentVariables: [
{
Name: 'INNER_VAR',
Type: 'PLAINTEXT',
Value: 'InnerValue',
},
{
Name: 'SOME_ENV_VAR',
Type: 'PLAINTEXT',
Value: 'SomeValue',
},
],
}),
Source: {
BuildSpec: encodedJson(deepObjectLike({
phases: {
pre_build: {
commands: ['install1', 'install2'],
},
build: {
commands: ['synth'],
},
},
})),
},
});
});

test.each([['npm'], ['yarn']])('%s can have its install command overridden', (npmYarn) => {
// WHEN
new TestGitHubNpmPipeline(pipelineStack, 'Cdk', {
Expand Down

0 comments on commit 41bf349

Please sign in to comment.