0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 13:38:32 +00:00
renovatebot_renovate/lib/modules/datasource/deb/url.spec.ts
oxdev03 c3958c9bd6
feat(datasource): add debian datasource (#30071)
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Sergei Zharinov <zharinov@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Aleksandr Mezin <mezin.alexander@gmail.com>
Co-authored-by: Jasmin Müller <9011011+jazzlyn@users.noreply.github.com>
2024-08-28 17:26:56 +00:00

41 lines
1.6 KiB
TypeScript

import { constructComponentUrls, getBaseReleaseUrl } from './url';
describe('modules/datasource/deb/url', () => {
it('constructs URLs correctly from registry URL with suite', () => {
const registryUrl =
'https://deb.debian.org/debian?suite=stable&components=main,contrib&binaryArch=amd64';
const expectedUrls = [
'https://deb.debian.org/debian/dists/stable/main/binary-amd64',
'https://deb.debian.org/debian/dists/stable/contrib/binary-amd64',
];
const componentUrls = constructComponentUrls(registryUrl);
expect(componentUrls).toEqual(expectedUrls);
});
it('constructs URLs correctly from registry URL with release', () => {
const registryUrl =
'https://deb.debian.org/debian?release=bullseye&components=main,contrib&binaryArch=amd64';
const expectedUrls = [
'https://deb.debian.org/debian/dists/bullseye/main/binary-amd64',
'https://deb.debian.org/debian/dists/bullseye/contrib/binary-amd64',
];
const componentUrls = constructComponentUrls(registryUrl);
expect(componentUrls).toEqual(expectedUrls);
});
it('throws an error if required parameters are missing', () => {
const registryUrl = 'https://deb.debian.org/debian?components=main,contrib';
expect(() => constructComponentUrls(registryUrl)).toThrow(
'Missing required query parameter',
);
});
it('returns the correct release url', () => {
const basePackageUrl =
'https://deb.debian.org/debian/dists/bullseye/main/binary-amd64';
const expectedUrl = 'https://deb.debian.org/debian/dists/bullseye';
expect(getBaseReleaseUrl(basePackageUrl)).toBe(expectedUrl);
});
});