tests/utils/gitUtils.test.js   A
last analyzed

Complexity

Total Complexity 3
Complexity/F 1

Size

Lines of Code 38
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 25
mnd 0
bc 0
fnc 3
dl 0
loc 38
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
1
import path from 'path';
2
import { assert } from 'chai';
3
import fs from 'fs-extra';
4
import { load } from '../utils';
5
import { testsRootFolder, tmpFolder } from '../constants';
6
import Test from '../Test';
7
8
const { getGitCommit } = load('utils/gitUtils');
9
const factory = new Test();
10
const tmpRepoDir = path.join(tmpFolder, 'repo');
11
12
suite('gitUtils');
13
14
before(async function () {
15
    await factory.setTmpFolder();
16
17
    await fs.copy(
18
        path.join(testsRootFolder, 'files/repository'),
19
        tmpRepoDir
20
    );
21
22
    await fs.move(
23
        path.join(tmpRepoDir, 'git_folder'),
24
        path.join(tmpRepoDir, '.git')
25
    );
26
});
27
28
test('Positive: getGitCommit', async function () {
29
    assert.equal(
30
        await getGitCommit(tmpRepoDir),
31
        '1c3e319b380a9572a80499984ba6f0c3341a3772'
32
    );
33
});
34
35
after(async function () {
36
    await factory.cleanTmpFolder();
37
    await fs.remove(tmpRepoDir);
38
});
39