Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(codepipeline): no longer allow providing an index when adding a S… #2624

Merged
merged 1 commit into from
May 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ export interface StagePlacement {
* (changing its current child Stage, if it had one).
*/
readonly justAfter?: IStage;

/**
* Inserts the new Stage at the given index in the Pipeline,
* moving the Stage currently at that index,
* and any subsequent ones, one index down.
* Indexing starts at 0.
* The maximum allowed value is {@link Pipeline#stageCount},
* which will insert the new Stage at the end of the Pipeline.
*/
readonly atIndex?: number;
}

/**
Expand Down Expand Up @@ -435,16 +425,6 @@ export class Pipeline extends PipelineBase {
return targetIndex + 1;
}

if (placement.atIndex !== undefined) {
const index = placement.atIndex;
if (index < 0 || index > this.stageCount) {
throw new Error("Error adding Stage to the Pipeline: " +
`{ placed: atIndex } should be between 0 and the number of stages in the Pipeline (${this.stageCount}), ` +
` got: ${index}`);
}
return index;
}

return this.stageCount;
}

Expand Down
54 changes: 0 additions & 54 deletions packages/@aws-cdk/aws-codepipeline/test/test.stages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,6 @@ import codepipeline = require('../lib');

export = {
'Pipeline Stages': {
'can be inserted at index 0'(test: Test) {
const stack = new cdk.Stack();
const pipeline = new codepipeline.Pipeline(stack, 'Pipeline');

pipeline.addStage({ name: 'SecondStage' });
pipeline.addStage({
name: 'FirstStage',
placement: {
atIndex: 0,
},
});

expect(stack, true).to(haveResourceLike('AWS::CodePipeline::Pipeline', {
"Stages": [
{ "Name": "FirstStage" },
{ "Name": "SecondStage" },
],
}));

test.done();
},

'can be inserted before another Stage'(test: Test) {
const stack = new cdk.Stack();
const pipeline = new codepipeline.Pipeline(stack, 'Pipeline');
Expand Down Expand Up @@ -75,38 +53,6 @@ export = {
test.done();
},

'attempting to insert a Stage at a negative index results in an error'(test: Test) {
const stack = new cdk.Stack();
const pipeline = new codepipeline.Pipeline(stack, 'Pipeline');

test.throws(() => {
pipeline.addStage({
name: 'Stage',
placement: {
atIndex: -1,
},
});
}, /atIndex/);

test.done();
},

'attempting to insert a Stage at an index larger than the current number of Stages results in an error'(test: Test) {
const stack = new cdk.Stack();
const pipeline = new codepipeline.Pipeline(stack, 'Pipeline');

test.throws(() => {
pipeline.addStage({
name: 'Stage',
placement: {
atIndex: 1,
},
});
}, /atIndex/);

test.done();
},

"attempting to insert a Stage before a Stage that doesn't exist results in an error"(test: Test) {
const stack = new cdk.Stack();
const pipeline = new codepipeline.Pipeline(stack, 'Pipeline');
Expand Down