diff --git a/packages/@aws-cdk/aws-codecommit-codepipeline/lib/pipeline-action.ts b/packages/@aws-cdk/aws-codecommit-codepipeline/lib/pipeline-action.ts index d21aaeb4a29f9..7c6016378186c 100644 --- a/packages/@aws-cdk/aws-codecommit-codepipeline/lib/pipeline-action.ts +++ b/packages/@aws-cdk/aws-codecommit-codepipeline/lib/pipeline-action.ts @@ -40,7 +40,7 @@ export class PipelineSource extends codepipeline.Source { configuration: { RepositoryName: props.repository.repositoryName, BranchName: props.branch || 'master', - PollForSourceChanges: props.pollForSourceChanges || true + PollForSourceChanges: props.pollForSourceChanges !== undefined ? props.pollForSourceChanges : true }, artifactName: props.artifactName }); diff --git a/packages/@aws-cdk/aws-codecommit-codepipeline/test/test.pipeline-action.ts b/packages/@aws-cdk/aws-codecommit-codepipeline/test/test.pipeline-action.ts new file mode 100644 index 0000000000000..a71c24ffbb43d --- /dev/null +++ b/packages/@aws-cdk/aws-codecommit-codepipeline/test/test.pipeline-action.ts @@ -0,0 +1,45 @@ +import codecommit = require("@aws-cdk/aws-codecommit"); +import codepipeline = require("@aws-cdk/aws-codepipeline"); +import cdk = require('@aws-cdk/cdk'); +import { Test } from 'nodeunit'; +import codecommitCodepipeline = require('../lib'); + +export = { + 'polling for changes': { + + 'does not poll for changes'(test: Test) { + const stack = new cdk.Stack(); + + const result = new codecommitCodepipeline.PipelineSource(stageForTesting(stack), 'stage', { + artifactName: 'SomeArtifact', + repository: repositoryForTesting(stack), + pollForSourceChanges: false + }); + test.equal(result.configuration.PollForSourceChanges, false); + test.done(); + }, + + 'polls for changes'(test: Test) { + const stack = new cdk.Stack(); + + const result = new codecommitCodepipeline.PipelineSource(stageForTesting(stack), 'stage', { + artifactName: 'SomeArtifact', + repository: repositoryForTesting(stack), + pollForSourceChanges: true + }); + test.equal(result.configuration.PollForSourceChanges, true); + test.done(); + } + } +}; + +function stageForTesting(stack: cdk.Stack): codepipeline.Stage { + const pipeline = new codepipeline.Pipeline(stack, 'pipeline'); + return new codepipeline.Stage(pipeline, 'stage'); +} + +function repositoryForTesting(stack: cdk.Stack): codecommit.Repository { + return new codecommit.Repository(stack, 'Repository', { + repositoryName: 'Repository' + }); +}