Skip to content

Commit

Permalink
chore(pipelines): test to make sure environment variables behave sane…
Browse files Browse the repository at this point in the history
…ly (aws#11906)

Make sure that environment variables combine correctly and a BuildSpec
is still rendered.

Relates to aws#11877.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr authored and flochaz committed Jan 5, 2021
1 parent e546670 commit ba2de0b
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 ba2de0b

Please sign in to comment.