2022-04-24 12:30:15 -06:00
|
|
|
import {describe, expect, it} from '@jest/globals';
|
|
|
|
import * as fs from 'fs';
|
2020-01-08 14:26:34 -07:00
|
|
|
import * as installer from '../src/installer';
|
|
|
|
|
2023-01-29 08:03:29 -07:00
|
|
|
describe('getRelease', () => {
|
|
|
|
it('returns latest UPX GitHub release', async () => {
|
|
|
|
const release = await installer.getRelease('latest');
|
|
|
|
expect(release).not.toBeNull();
|
|
|
|
expect(release?.tag_name).not.toEqual('');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('returns v3.95 UPX GitHub release', async () => {
|
|
|
|
const release = await installer.getRelease('v3.95');
|
|
|
|
expect(release).not.toBeNull();
|
|
|
|
expect(release?.id).toEqual(12577195);
|
|
|
|
expect(release?.tag_name).toEqual('v3.95');
|
|
|
|
expect(release?.html_url).toEqual('https://github.com/upx/upx/releases/tag/v3.95');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('unknown release', async () => {
|
2023-09-09 21:28:51 -06:00
|
|
|
await expect(installer.getRelease('foo')).rejects.toThrow(
|
2023-01-29 08:03:29 -07:00
|
|
|
new Error(
|
|
|
|
'Cannot find UPX release foo in https://raw.githubusercontent.com/crazy-max/ghaction-upx/master/.github/upx-releases.json'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-01-08 14:26:34 -07:00
|
|
|
describe('installer', () => {
|
2020-05-07 04:11:19 -06:00
|
|
|
it('acquires v3.95 version of UPX', async () => {
|
|
|
|
const upx = await installer.getUPX('v3.95');
|
2020-01-08 14:26:34 -07:00
|
|
|
expect(fs.existsSync(upx)).toBe(true);
|
|
|
|
}, 100000);
|
|
|
|
|
|
|
|
it('acquires latest version of UPX', async () => {
|
|
|
|
const upx = await installer.getUPX('latest');
|
|
|
|
expect(fs.existsSync(upx)).toBe(true);
|
|
|
|
}, 100000);
|
|
|
|
});
|