Skip to content

Commit

Permalink
fix(core): BundlingDockerImage.fromAsset() does not return a Bundling…
Browse files Browse the repository at this point in the history
…DockerImage (aws#13846)

A previous change missed to fix the 'return' statement on this method.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
Niranjan Jayakar authored and hollanddd committed Aug 26, 2021
1 parent e39821f commit 23e8514
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/core/lib/bundling.ts
Expand Up @@ -157,8 +157,8 @@ export class BundlingDockerImage {
*
* @deprecated use DockerImage.fromBuild()
*/
public static fromAsset(path: string, options: DockerBuildOptions = {}) {
DockerImage.fromBuild(path, options) as BundlingDockerImage;
public static fromAsset(path: string, options: DockerBuildOptions = {}): BundlingDockerImage {
return DockerImage.fromBuild(path, options);
}

/** @param image The Docker image */
Expand Down
19 changes: 19 additions & 0 deletions packages/@aws-cdk/core/test/bundling.test.ts
Expand Up @@ -173,6 +173,25 @@ nodeunitShim({
test.done();
},

'fromAsset'(test: Test) {
sinon.stub(child_process, 'spawnSync').returns({
status: 0,
stderr: Buffer.from('stderr'),
stdout: Buffer.from('sha256:1234567890abcdef'),
pid: 123,
output: ['stdout', 'stderr'],
signal: null,
});

const imagePath = path.join(__dirname, 'fs/fixtures/test1');
const image = BundlingDockerImage.fromAsset(imagePath, {
file: 'my-dockerfile',
});
test.ok(image);
test.ok(image.image);
test.done();
},

'custom entrypoint is passed through to docker exec'(test: Test) {
const spawnSyncStub = sinon.stub(child_process, 'spawnSync').returns({
status: 0,
Expand Down

0 comments on commit 23e8514

Please sign in to comment.