docker-mock

Mock for Docker

docker-mock

A mock for Docker!

Require it from your node program:

var dockerMock = require('docker-mock');
dockerMock.listen(5354);

You can also use the command line interface, just run docker-mock after installing the package globally.

See the tests for some sample usage, but you should be able to point your docker client at this mock and test against it.

This does have support for simulating failures during build. This is done (using dockerode) by doing the following:

// file is a tar containing at minimum a Dockerfile 
var file = ...;
docker.buildImage(
  file,
  {
    t: 'doomedImage',
    fail: true
  },
  function (errres) {
    // err will not be null 
  });

If you want to disable randomly generated events exposed under /events endpoint please use ENV var: DISABLE_RANDOM_EVENTS=true.

You can manually emit docker mock events.

  var dockerMock = require('docker-mock');
  dockerMock.listen(5354);
  dockerMock.events.stream.emit('data', JSON.stringify({status: 'die', from: '..', id: '...', time: '...'}));
  // or 
  dockerMock.events.stream.emit('data', dockerMock.events.generateEvent());
 

This is currently a work in progress, being built up as use cases come to light. If you would like to contribute, please note this repository is using a git-flow pattern, so please submit pull requests against the develop branch, and they will be merged into the future release branch and master.

Please make sure all unit tests pass and coverage remains high during development (see below for details).

Testing is done locally via npm test.

Coverage is now run by Lab via npm test. Output at the bottom shows percent coverage verses a threshold set in package.json.