const touch = require('touch');
const sinon = require('sinon');
const should = require('chai').should();
const proxyquire = require('proxyquire');
var AWS = require('aws-sdk');
var ec2 = new AWS.EC2({
  apiVersion: '2014-10-01'
, region: 'us-west-2'
});

var InstancePool = require('./../lib/InstancePool');
var Helper = require('./test_helper');

var pool;
var stub;

before(function(done) {
  pool = new InstancePool();
  pool.ec2 = ec2;
  done();
})

after(function(done) {
  if (stub) { stub.restore(); }
  done();
})

describe('InstancePool', function() {

  describe('constructor', function() {

    it ('defaults to the NaiveStrategy', function(done) {
      var pool = new InstancePool();
      pool.strategy().should.equal('NaiveStrategy');
      done();
    })

  })

  describe('#startSshPolling', function() {

    it('polls instances', function(done) {

      done();
    })

  })

})

@@ -360,16 +360,27 @@
 ar stub;
+%0Avar clock;
 %0A%0Abefore
@@ -513,16 +513,50 @@
 re(); %7D%0A
+  if (clock) %7B clock.restore(); %7D%0A
   done()
@@ -904,29 +904,787 @@
 done) %7B%0A
-%0A      done()
+      var tagsStub = %7B%7D;%0A      tagsStub.applyTags = function(tags, instanceId, callback) %7B%0A        callback(instanceId);%0A      %7D%0A      var InstancePool = proxyquire('./../lib/InstancePool', %7B './Tags': tagsStub %7D);%0A      Instances.ec2 = ec2;%0A%0A      var now = new Date();%0A      clock = sinon.useFakeTimers(now.getTime());%0A%0A      done();%0A    %7D)%0A%0A  %7D)%0A%0A  describe('#removeFromPool', function() %7B%0A%0A    it('removes pool tags', function(done) %7B%0A      var tagsStub = %7B%7D;%0A      tagsStub.removeTags = function(tags, instanceId, callback) %7B%0A        callback();%0A      %7D%0A      var InstancePool = proxyquire('./../lib/InstancePool', %7B './Tags': tagsStub %7D);%0A%0A      const id = 42;%0A      var spy = sinon.spy();%0A      InstancePool.removeFromPool(id, spy);%0A      spy.called.should.be.true
 ;%0A    %7D)

Test ssh polling