Skip to content

Commit

Permalink
Merge pull request #211 from CollinEstes/load-image
Browse files Browse the repository at this point in the history
Enable stream input on loadImage
  • Loading branch information
apocas committed Jan 20, 2016
2 parents 09b125f + 3918beb commit 9a2067b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
24 changes: 24 additions & 0 deletions test/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Binary file added test/test-load.tar
Binary file not shown.

0 comments on commit 9a2067b

Please sign in to comment.