-
Notifications
You must be signed in to change notification settings - Fork 1
/
prepare.test.js
46 lines (44 loc) · 1.59 KB
/
prepare.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
let prepare = require('./prepare');
let fs = require('fs');
const core = require('@actions/core');
describe('prepare functions', () => {
let options = "{ silent: true }"
describe('uploadArtifacts', () => {
test('file not found', async() => {
fs.closeSync(fs.openSync('./test', 'w'));
await expect(
prepare.uploadArtifacts(
"artifactName",
['test','test2','./test3'],
"./"
)
).rejects.toThrowError(/Error: cannot find test2 on host in .\//);
fs.unlinkSync('./test');
}); // TEST
test('folder not allowed', async() => {
await expect(
prepare.uploadArtifacts(
"artifactName",
['testFolder','test2','./test3'],
"./"
)
).rejects.toThrowError(/Error: unable to archive directories/);
}); // TEST
}); // DESCRIBE
describe('deleteLockFile', () => {
afterEach(() => {
try{ fs.unlinkSync('/tmp/registry-pull-lock-10.15.6'); } catch(error) {}
core.exportVariable(`${process.env['GITHUB_ACTION']}_hasPullLockFile`, false)
});
test('file exists', async() => {
core.exportVariable(`${process.env['GITHUB_ACTION']}_hasPullLockFile`, true)
fs.closeSync(fs.openSync('/tmp/registry-pull-lock-10.15.6', 'w'));
await prepare.deleteLockFile("10.15.6")
await expect(fs.existsSync("/tmp/registry-pull-lock-10.15.6")).toBe(false)
}); // TEST
test('no file, no problem', async() => {
await prepare.deleteLockFile("10.15.6")
await expect(fs.existsSync("/tmp/registry-pull-lock-10.15.6")).toBe(false)
}); // TEST
}); // DESCRIBE
});