var common = require('../common');
var Airbrake = require(common.dir.root);
var airbrake = Airbrake.createClient(null, common.key);
var sinon = require('sinon');
var assert = require('assert');

var spy = sinon.spy();
airbrake.trackDeployment({
  rev: '98103a8fa850d5eaf3666e419d8a0a93e535b1b2'
}, spy);

process.on('exit', function () {
  assert.strictEqual(spy.args[0][0], null);
  assert.deepEqual(Object.keys(spy.args[0][1]), [
    'key',
    'env',
    'user',
    'rev',
    'repo'
  ]);
  assert.equal(spy.args[0][1].repo, 'git@github.com:airbrake/node-airbrake.git');
  assert.equal(spy.args[0][1].rev, '98103a8fa850d5eaf3666e419d8a0a93e535b1b2');
});

var common = require('../common');
var Airbrake = require(common.dir.root);
var airbrake = Airbrake.createClient(null, common.key);
var sinon = require('sinon');
var assert = require('assert');
var execSync = require('sync-exec');

var spy = sinon.spy();
airbrake.trackDeployment({}, spy);

process.on('exit', function () {
  assert.strictEqual(spy.args[0][0], null);
  assert.deepEqual(Object.keys(spy.args[0][1]), [
    'key',
    'env',
    'user',
    'rev',
    'repo'
  ]);

  var expectedRepo = execSync('git config --get remote.origin.url')
    .stdout
    .toString()
    .slice(0, -1);

  var expectedRev = execSync('git rev-parse HEAD')
    .stdout
    .toString()
    .slice(0, -1);


  assert.equal(spy.args[0][1].repo, expectedRepo);
  assert.equal(spy.args[0][1].rev, expectedRev);
});

Update deployment test to work in development In test-track-deployment.js, the revision and Git remote values are hard-coded. This commit adds dynamic determination of Git remote and revision so it works on anyone's branch of node-airbrake.