Skip to content

Commit

Permalink
chore(codebuild): props parameter of metric() method to be optional (#…
Browse files Browse the repository at this point in the history
…6633)

All properties of `MethodOptions` are optional.
  • Loading branch information
nija-at authored Mar 9, 2020
1 parent 4e91cb4 commit 76bdccb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-codebuild/lib/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export interface IProject extends IResource, iam.IGrantable, ec2.IConnectable {
* @param metricName The name of the metric
* @param props Customization properties
*/
metric(metricName: string, props: cloudwatch.MetricOptions): cloudwatch.Metric;
metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric;

/**
* Measures the number of builds triggered.
Expand Down Expand Up @@ -316,7 +316,7 @@ abstract class ProjectBase extends Resource implements IProject {
* @param metricName The name of the metric
* @param props Customization properties
*/
public metric(metricName: string, props: cloudwatch.MetricOptions) {
public metric(metricName: string, props?: cloudwatch.MetricOptions) {
return new cloudwatch.Metric({
namespace: 'AWS/CodeBuild',
metricName,
Expand Down
17 changes: 17 additions & 0 deletions packages/@aws-cdk/aws-codebuild/test/test.project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,21 @@ export = {

test.done();
},

'metric method generates a valid CloudWatch metric'(test: Test) {
const stack = new cdk.Stack();

const project = new codebuild.Project(stack, 'Project', {
source: codebuild.Source.gitHubEnterprise({
httpsCloneUrl: 'https://mygithub-enterprise.com/myuser/myrepo',
})
});

const metric = project.metric('Builds');
test.equal(metric.metricName, 'Builds');
test.equal(metric.period.toSeconds(), cdk.Duration.minutes(5).toSeconds());
test.equal(metric.statistic, 'Average');

test.done();
}
};

0 comments on commit 76bdccb

Please sign in to comment.