Giter Club home page Giter Club logo

docker-mock's Introduction

docker-mock

Build Status Dependency Status devDependency Status Code Climate Test Coverage

NPM

A mock for Docker!

Usage

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.

Examples

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

Failures

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 (err, res) {
    // err will not be null
  });

Configuration

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

Events

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());

Contributing

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

Testing

Testing is done locally via npm test.

Coverage

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.