fix: downloads

This commit is contained in:
Filip Richtarik 2024-02-03 03:04:41 +01:00 committed by Filip Richtárik
parent 7db63f5e7f
commit f2109f1312
18 changed files with 72 additions and 56 deletions

View file

@ -2,9 +2,9 @@ import getArch from '../src/get-arch';
describe('getArch', () => {
test('processor architecture', () => {
expect(getArch('x64')).toBe('64bit');
expect(getArch('arm')).toBe('ARM');
expect(getArch('arm64')).toBe('ARM64');
expect(getArch('x64')).toBe('amd64');
expect(getArch('arm')).toBe('arm');
expect(getArch('arm64')).toBe('arm64');
});
test('exception', () => {

View file

@ -2,9 +2,9 @@ import getOS from '../src/get-os';
describe('getOS', () => {
test('os type', () => {
expect(getOS('linux')).toBe('Linux');
expect(getOS('darwin')).toBe('macOS');
expect(getOS('win32')).toBe('Windows');
expect(getOS('linux')).toBe('linux');
expect(getOS('darwin')).toBe('darwin');
expect(getOS('win32')).toBe('windows');
});
test('exception', () => {

View file

@ -2,19 +2,19 @@ import getURL from '../src/get-url';
describe('getURL()', () => {
test('get a URL to an asset for each platform', () => {
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.58.2';
const urlLinux = `${baseURL}/hugo_0.58.2_Linux-64bit.tar.gz`;
const urlLinuxExtended = `${baseURL}/hugo_extended_0.58.2_Linux-64bit.tar.gz`;
const urlMacOS = `${baseURL}/hugo_0.58.2_macOS-64bit.tar.gz`;
const urlMacOSExtended = `${baseURL}/hugo_extended_0.58.2_macOS-64bit.tar.gz`;
const urlWindows = `${baseURL}/hugo_0.58.2_Windows-64bit.zip`;
expect(getURL('Linux', '64bit', 'false', '0.58.2')).toBe(urlLinux);
expect(getURL('Linux', '64bit', 'true', '0.58.2')).not.toBe(urlLinux);
expect(getURL('MyOS', '64bit', 'false', '0.58.2')).not.toBe(urlLinux);
expect(getURL('Linux', '64bit', 'false', '0.58.1')).not.toBe(urlLinux);
expect(getURL('Linux', '64bit', 'true', '0.58.2')).toBe(urlLinuxExtended);
expect(getURL('macOS', '64bit', 'false', '0.58.2')).toBe(urlMacOS);
expect(getURL('macOS', '64bit', 'true', '0.58.2')).toBe(urlMacOSExtended);
expect(getURL('Windows', '64bit', 'false', '0.58.2')).toBe(urlWindows);
const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.122.0';
const urlLinux = `${baseURL}/hugo_0.122.0_linux-amd64.tar.gz`;
const urlLinuxExtended = `${baseURL}/hugo_extended_0.122.0_linux-amd64.tar.gz`;
const urlMacOS = `${baseURL}/hugo_0.122.0_darwin-universal.tar.gz`;
const urlMacOSExtended = `${baseURL}/hugo_extended_0.122.0_darwin-universal.tar.gz`;
const urlWindows = `${baseURL}/hugo_0.122.0_windows-amd64.zip`;
expect(getURL('linux', 'amd64', 'false', '0.122.0')).toBe(urlLinux);
expect(getURL('linux', 'amd64', 'true', '0.122.0')).not.toBe(urlLinux);
expect(getURL('MyOS', 'amd64', 'false', '0.122.0')).not.toBe(urlLinux);
expect(getURL('linux', 'amd64', 'false', '0.121.0')).not.toBe(urlLinux);
expect(getURL('linux', 'amd64', 'true', '0.122.0')).toBe(urlLinuxExtended);
expect(getURL('darwin', 'universal', 'false', '0.122.0')).toBe(urlMacOS);
expect(getURL('darwin', 'universal', 'true', '0.122.0')).toBe(urlMacOSExtended);
expect(getURL('windows', 'amd64', 'false', '0.122.0')).toBe(urlWindows);
});
});