@@ -1046,6 +1046,40 @@ export = {
1046
1046
} ) ;
1047
1047
} , / W i n d o w s i m a g e s d o n o t s u p p o r t t h e S m a l l C o m p u t e T y p e / ) ;
1048
1048
1049
+ test . done ( ) ;
1050
+ } ,
1051
+
1052
+ 'badge support test' ( test : Test ) {
1053
+ const stack = new cdk . Stack ( ) ;
1054
+
1055
+ interface BadgeValidationTestCase {
1056
+ source : codebuild . BuildSource ,
1057
+ shouldPassValidation : boolean
1058
+ }
1059
+
1060
+ const repo = new codecommit . Repository ( stack , 'MyRepo' , { repositoryName : 'hello-cdk' } ) ;
1061
+ const bucket = new s3 . Bucket ( stack , 'MyBucket' ) ;
1062
+
1063
+ const cases : BadgeValidationTestCase [ ] = [
1064
+ { source : new codebuild . NoSource ( ) , shouldPassValidation : false } ,
1065
+ { source : new codebuild . CodePipelineSource ( ) , shouldPassValidation : false } ,
1066
+ { source : new codebuild . CodeCommitSource ( { repository : repo } ) , shouldPassValidation : false } ,
1067
+ { source : new codebuild . S3BucketSource ( { bucket, path : 'path/to/source.zip' } ) , shouldPassValidation : false } ,
1068
+ { source : new codebuild . GitHubSource ( { owner : 'awslabs' , repo : 'aws-cdk' , oauthToken : new cdk . SecretValue ( ) } ) , shouldPassValidation : true } ,
1069
+ { source : new codebuild . GitHubEnterpriseSource ( { httpsCloneUrl : 'url' , oauthToken : new cdk . SecretValue ( ) } ) , shouldPassValidation : true } ,
1070
+ { source : new codebuild . BitBucketSource ( { owner : 'awslabs' , repo : 'aws-cdk' } ) , shouldPassValidation : true }
1071
+ ] ;
1072
+
1073
+ cases . forEach ( testCase => {
1074
+ const source = testCase . source ;
1075
+ const validationBlock = ( ) => { new codebuild . Project ( stack , `MyProject-${ source . type } ` , { source, badge : true } ) ; } ;
1076
+ if ( testCase . shouldPassValidation ) {
1077
+ test . doesNotThrow ( validationBlock , Error , `Badge is not supported for source type ${ source . type } ` ) ;
1078
+ } else {
1079
+ test . throws ( validationBlock , Error , `Badge is not supported for source type ${ source . type } ` ) ;
1080
+ }
1081
+ } ) ;
1082
+
1049
1083
test . done ( ) ;
1050
1084
}
1051
1085
} ;
0 commit comments