1 | (function (util, getGitData, helper) {
|
2 | 'use strict';
|
3 |
|
4 | var expect = helper.chai.expect;
|
5 | var actualTravisCommit = process.env.TRAVIS_COMMIT;
|
6 |
|
7 | describe('Get Git Data', function () {
|
8 | beforeEach(function () {
|
9 | helper.clearEnvironmentVariables();
|
10 | });
|
11 | it('should be able to get the commit id when one is passed', function () {
|
12 | return expect(getGitData.getCommitId('1234')).to.eventually.equal('1234');
|
13 | });
|
14 | it('should be able to get the commit id from the Codacy environment variable', function () {
|
15 | process.env.CODACY_GIT_COMMIT = '1234';
|
16 | return expect(getGitData.getCommitId()).to.eventually.equal('1234');
|
17 | });
|
18 | it('should be able to get the commit id from the Travis CI environment variable', function () {
|
19 | process.env.TRAVIS_COMMIT = '4321';
|
20 | return expect(getGitData.getCommitId()).to.eventually.equal('4321');
|
21 | });
|
22 | it('should be able to get the commit id from the Drone environment variable', function () {
|
23 | process.env.DRONE_COMMIT = '42';
|
24 | return expect(getGitData.getCommitId()).to.eventually.equal('42');
|
25 | });
|
26 | it('should be able to get the commit id from the Jenkins environment variable', function () {
|
27 | process.env.GIT_COMMIT = '16';
|
28 | return expect(getGitData.getCommitId()).to.eventually.equal('16');
|
29 | });
|
30 | it('should be able to get the commit id from the Circle CI environment variable', function () {
|
31 | process.env.CIRCLE_SHA1 = '743';
|
32 | return expect(getGitData.getCommitId()).to.eventually.equal('743');
|
33 | });
|
34 | it('should be able to get the commit id from the CI environment variable', function () {
|
35 | process.env.CI_COMMIT_ID = '209';
|
36 | return expect(getGitData.getCommitId()).to.eventually.equal('209');
|
37 | });
|
38 | it('should be able to get the commit id from the Wrecker environment variable', function () {
|
39 | process.env.WERCKER_GIT_COMMIT = '5232';
|
40 | return expect(getGitData.getCommitId()).to.eventually.equal('5232');
|
41 | });
|
42 | it('should be able to get the commit id from Git', function () {
|
43 |
|
44 |
|
45 |
|
46 | if (actualTravisCommit && process.env.TRAVIS_PULL_REQUEST === 'false') {
|
47 | return expect(getGitData.getCommitId()).to.eventually.equal(actualTravisCommit);
|
48 | }
|
49 | return expect(getGitData.getCommitId()).to.eventually.be.fulfilled();
|
50 | });
|
51 | });
|
52 | }(require('util'), require('../lib/getGitData'), require('./helper')));
|