/*
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

'use strict';

var assert = require('assert');
var logger = require('bunyan').createLogger({ name: 'deploy-test' });
var Deployer = require('../../lib/deployer');
var OutMock = require('../mocks/out.js');

describe('deploy test', function() {
  it('should deploy an empty plan', function(done) {
    var deployer = new Deployer({ logger: logger }, {});
    deployer.deployPlan({}, {}, [], 'live', new OutMock(logger), function(err) {
      assert(!err);
      done();
    });
  });



  it('should fail to deploy a plan with no suitable containers', function(done) {
    var deployer = new Deployer({ logger: logger }, {});
    var sysdef = require('../data/sysdef.json');
    deployer.deployPlan(sysdef, sysdef, [
      {
        id: '20',
        cmd: 'deploy',
        parent: '10'
      }
    ], 'live', new OutMock(logger), function(err) {
      assert(err);
      done();
    });
  });
});

@@ -931,16 +931,61 @@
 ut.js');
+%0Avar sysdef = require('../data/sysdef.json');
 %0A%0Adescri
@@ -1400,57 +1400,8 @@
 %7D);%0A
-    var sysdef = require('../data/sysdef.json');%0A
     
@@ -1560,32 +1560,32 @@
 function(err) %7B%0A
-
       assert(err
@@ -1615,12 +1615,670 @@
 ;%0A  %7D);%0A
+%0A%0A%0A  it('should call container-specific deploy function', function(done) %7B%0A    var deployCalled = false;%0A    var deployer = new Deployer(%7B logger: logger %7D, %7B%0A      docker: %7B%0A        deploy: function(mode, specific, target, containerDef, container, out, done) %7B%0A          deployCalled = true;%0A          assert.equal(mode, 'live');%0A          done();%0A        %7D%0A      %7D%0A    %7D);%0A%0A    deployer.deployPlan(sysdef, sysdef, %5B%0A      %7B%0A        id: 'c5c9ceb9-21b3-4d56-81e7-4bff829a5c45',%0A        cmd: 'deploy',%0A        parent: '10'%0A      %7D%0A    %5D, 'live', new OutMock(logger), function(err) %7B%0A      assert(!err);%0A      assert(deployCalled);%0A      done();%0A    %7D);%0A  %7D);%0A
 %7D);%0A

Test if deployer calls container-specific functions