11import cpapi = require( '@aws-cdk/aws-codepipeline-api' ) ;
2+ import events = require( '@aws-cdk/aws-events' ) ;
23import iam = require( '@aws-cdk/aws-iam' ) ;
34import cdk = require( '@aws-cdk/cdk' ) ;
45import _ = require( 'lodash' ) ;
@@ -10,7 +11,7 @@ export = nodeunit.testCase({
1011 'works' ( test : nodeunit . Test ) {
1112 const stack = new cdk . Stack ( ) ;
1213 const pipelineRole = new RoleDouble ( stack , 'PipelineRole' ) ;
13- const stage = new StageDouble ( { pipelineRole } ) ;
14+ const stage = new StageDouble ( { pipeline : new PipelineDouble ( { role : pipelineRole } ) } ) ;
1415 const artifact = new cpapi . Artifact ( stack as any , 'TestArtifact' ) ;
1516 const action = new cloudformation . PipelineCreateReplaceChangeSetAction ( stack , 'Action' , {
1617 stage,
@@ -43,7 +44,7 @@ export = nodeunit.testCase({
4344 'uses a single permission statement if the same ChangeSet name is used' ( test : nodeunit . Test ) {
4445 const stack = new cdk . Stack ( ) ;
4546 const pipelineRole = new RoleDouble ( stack , 'PipelineRole' ) ;
46- const stage = new StageDouble ( { pipelineRole } ) ;
47+ const stage = new StageDouble ( { pipeline : new PipelineDouble ( { role : pipelineRole } ) } ) ;
4748 const artifact = new cpapi . Artifact ( stack as any , 'TestArtifact' ) ;
4849 new cloudformation . PipelineCreateReplaceChangeSetAction ( stack , 'ActionA' , {
4950 stage,
@@ -97,7 +98,7 @@ export = nodeunit.testCase({
9798 'works' ( test : nodeunit . Test ) {
9899 const stack = new cdk . Stack ( ) ;
99100 const pipelineRole = new RoleDouble ( stack , 'PipelineRole' ) ;
100- const stage = new StageDouble ( { pipelineRole } ) ;
101+ const stage = new StageDouble ( { pipeline : new PipelineDouble ( { role : pipelineRole } ) } ) ;
101102 new cloudformation . PipelineExecuteChangeSetAction ( stack , 'Action' , {
102103 stage,
103104 changeSetName : 'MyChangeSet' ,
@@ -120,7 +121,7 @@ export = nodeunit.testCase({
120121 'uses a single permission statement if the same ChangeSet name is used' ( test : nodeunit . Test ) {
121122 const stack = new cdk . Stack ( ) ;
122123 const pipelineRole = new RoleDouble ( stack , 'PipelineRole' ) ;
123- const stage = new StageDouble ( { pipelineRole } ) ;
124+ const stage = new StageDouble ( { pipeline : new PipelineDouble ( { role : pipelineRole } ) } ) ;
124125 new cloudformation . PipelineExecuteChangeSetAction ( stack , 'ActionA' , {
125126 stage,
126127 changeSetName : 'MyChangeSet' ,
@@ -158,7 +159,7 @@ export = nodeunit.testCase({
158159 const stack = new cdk . Stack ( ) ;
159160 const pipelineRole = new RoleDouble ( stack , 'PipelineRole' ) ;
160161 const action = new cloudformation . PipelineCreateUpdateStackAction ( stack , 'Action' , {
161- stage : new StageDouble ( { pipelineRole } ) ,
162+ stage : new StageDouble ( { pipeline : new PipelineDouble ( { role : pipelineRole } ) } ) ,
162163 templatePath : new cpapi . Artifact ( stack as any , 'TestArtifact' ) . atPath ( 'some/file' ) ,
163164 stackName : 'MyStack' ,
164165 replaceOnFailure : true ,
@@ -179,7 +180,7 @@ export = nodeunit.testCase({
179180 const stack = new cdk . Stack ( ) ;
180181 const pipelineRole = new RoleDouble ( stack , 'PipelineRole' ) ;
181182 const action = new cloudformation . PipelineDeleteStackAction ( stack , 'Action' , {
182- stage : new StageDouble ( { pipelineRole } ) ,
183+ stage : new StageDouble ( { pipeline : new PipelineDouble ( { role : pipelineRole } ) } ) ,
183184 stackName : 'MyStack' ,
184185 } ) ;
185186 const stackArn = _stackArn ( 'MyStack' ) ;
@@ -273,26 +274,42 @@ function _stackArn(stackName: string): string {
273274 } ) ;
274275}
275276
276- class StageDouble implements cpapi . IStage , cpapi . IInternalStage {
277- public readonly name : string ;
277+ class PipelineDouble implements cpapi . IPipeline {
278278 public readonly pipelineArn : string ;
279- public readonly pipelineRole : iam . Role ;
280- public readonly _internal = this ;
279+ public readonly role : iam . Role ;
281280
282- public readonly actions = new Array < cpapi . Action > ( ) ;
283-
284- constructor ( { name, pipelineName, pipelineRole } : { name ?: string , pipelineName ?: string , pipelineRole : iam . Role } ) {
285- this . name = name || 'TestStage' ;
281+ constructor ( { pipelineName, role } : { pipelineName ?: string , role : iam . Role } ) {
286282 this . pipelineArn = cdk . ArnUtils . fromComponents ( { service : 'codepipeline' , resource : 'pipeline' , resourceName : pipelineName || 'TestPipeline' } ) ;
287- this . pipelineRole = pipelineRole ;
283+ this . role = role ;
288284 }
289285
290- public grantPipelineBucketRead ( ) {
291- throw new Error ( ' Unsupported' ) ;
286+ public get uniqueId ( ) : string {
287+ throw new Error ( " Unsupported" ) ;
292288 }
293289
294- public grantPipelineBucketReadWrite ( ) {
295- throw new Error ( 'Unsupported' ) ;
290+ public grantBucketRead ( ) : void {
291+ throw new Error ( "Unsupported" ) ;
292+ }
293+
294+ public grantBucketReadWrite ( ) : void {
295+ throw new Error ( "Unsupported" ) ;
296+ }
297+
298+ public asEventRuleTarget ( ) : events . EventRuleTargetProps {
299+ throw new Error ( "Unsupported" ) ;
300+ }
301+ }
302+
303+ class StageDouble implements cpapi . IStage , cpapi . IInternalStage {
304+ public readonly name : string ;
305+ public readonly pipeline : cpapi . IPipeline ;
306+ public readonly _internal = this ;
307+
308+ public readonly actions = new Array < cpapi . Action > ( ) ;
309+
310+ constructor ( { name, pipeline } : { name ?: string , pipeline : cpapi . IPipeline } ) {
311+ this . name = name || 'TestStage' ;
312+ this . pipeline = pipeline ;
296313 }
297314
298315 public _attachAction ( action : cpapi . Action ) {
0 commit comments