-
Notifications
You must be signed in to change notification settings - Fork 195
/
validate.test.ts
39 lines (33 loc) · 1007 Bytes
/
validate.test.ts
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
import validateUploader, {retrieveChecksum} from './validate';
const request = require('requestretry');
const bashScript = (async () => {
try {
const script = await request({
json: false,
maxAttempts: 10,
timeout: 3000,
url: 'https://codecov.io/bash',
});
return script.body;
} catch (err) {
throw err;
}
});
test('valid checksums', async () => {
const valid = await validateUploader(await bashScript());
expect(valid).toBeTruthy();
});
test('invalid checksums', async () => {
const script = await bashScript();
const valid = await validateUploader(script.substring(0, script.length - 1));
expect(valid).toBeFalsy();
});
test('invalid script version', async () => {
const script = await bashScript();
const valid = await validateUploader(script.substring(0, 20));
expect(valid).toBeFalsy();
});
test('invalid public checksum file', async () => {
const checksum = await retrieveChecksum('foo', 'bar');
expect(checksum).toBeFalsy();
});