From 3918beb79ab28c9b17e64f5b8f264dda8c1ca4ca Mon Sep 17 00:00:00 2001 From: Collin Estes Date: Mon, 11 Jan 2016 14:55:55 -0600 Subject: [PATCH] Enable stream input on loadImage Also added loadImage test case. --- lib/docker.js | 1 + test/docker.js | 24 ++++++++++++++++++++++++ test/test-load.tar | Bin 0 -> 13824 bytes 3 files changed, 25 insertions(+) create mode 100644 test/test-load.tar diff --git a/lib/docker.js b/lib/docker.js index fe6d164..138b54c 100644 --- a/lib/docker.js +++ b/lib/docker.js @@ -88,6 +88,7 @@ Docker.prototype.loadImage = function(file, opts, callback) { method: 'POST', options: opts, file: file, + isStream: true, statusCodes: { 200: true, 500: 'server error' diff --git a/test/docker.js b/test/docker.js index 817daa9..f0d27b3 100644 --- a/test/docker.js +++ b/test/docker.js @@ -80,6 +80,30 @@ describe("#docker", function() { }); }); + + describe("#loadImage", function() { + it("should load image from readable stream", function(done) { + this.timeout(60000); + + function handler(err, stream) { + expect(err).to.be.null; + expect(stream).to.be.ok; + + stream.pipe(process.stdout, { + end: true + }); + + stream.on('end', function() { + done(); + }); + } + + // test-save.tar => 'docker save hello-world > ./test/test-save.tar + var data = require('fs').createReadStream('./test/test-load.tar'); + docker.loadImage(data, {}, handler); + }); + }); + describe("#getEvents", function() { it("should get events", function(done) { this.timeout(30000); diff --git a/test/test-load.tar b/test/test-load.tar new file mode 100644 index 0000000000000000000000000000000000000000..0d0509bc20712be5e276b790da2dcaa275ef7305 GIT binary patch literal 13824 zcmeHN+iu)85Z$E6%f93nShWu=VDE}IT^2==G>apE2dL zK*&G@#1}+~AfhzjJXVr>jL;w=ijN0pAFd1NoDbagSiRcP0VW>fE~X$maIx=GcYyfW z(A_2KvJwTD)D>y9b6xR1kUs6||0kQ@@7&vd_%3r@?7AKUzqZHf6-wzz{}b2uyaDR$ zlXn@lsJr6+$DzM8mI${2V1tU&~%REBqPgd0AmC(5=K$tTUM2tpQP?ccM zi(?2pd0bQ6&ZXV7|sp3bbs7hy& z*J--uJ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