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

Complexity

Total Complexity 5
Complexity/F 1.25

Size

Lines of Code 49
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 30
mnd 1
bc 1
fnc 4
dl 0
loc 49
bpm 0.25
cpm 1.25
noi 0
c 0
b 0
f 0
rs 10
1
import path from 'path';
2
import { assert } from 'chai';
3
import fs from 'fs-extra';
4
import Test, { load, fixturesFolder, tmpFolder } from '../Test';
5
6
import '../utils';
7
8
const { tarball } = load('utils');
9
const t = new Test();
10
11
suite('tar');
12
13
before(async function () {
14
    await t.setTmpFolder();
15
});
16
17
test('Positive: pack folder default ignore', async function () {
18
    const file = await tarball(
19
        path.join(fixturesFolder, 'txt_file'),
20
        tmpFolder
21
    );
22
23
    await assert.isTarEqual(file, path.join(fixturesFolder, 'txt_file.tar'));
24
});
25
26
27
test('Positive: pack folder with .gitignore', async function () {
28
    await fs.move(
29
        path.join(fixturesFolder, 'gitignore', '.herokuignore'),
30
        path.join(fixturesFolder, 'gitignore', '.gitignore')
31
    );
32
    try {
33
        const file = await tarball(
34
            path.join(fixturesFolder, 'gitignore'),
35
            tmpFolder
36
        );
37
38
        await assert.isTarEqual(file, path.join(fixturesFolder, 'gitignore.tar'));
39
    } finally {
40
        await fs.move(
41
            path.join(fixturesFolder, 'gitignore', '.gitignore'),
42
            path.join(fixturesFolder, 'gitignore', '.herokuignore')
43
        );
44
    }
45
});
46
47
after(async function () {
48
    await t.cleanTmpFolder();
49
});
50