2022-02-15 05:12:30 +00:00
|
|
|
import { MavenDatasource } from './maven';
|
2022-08-25 17:18:51 +00:00
|
|
|
import {
|
|
|
|
addMetaData,
|
|
|
|
massageGithubUrl,
|
|
|
|
shouldDeleteHomepage,
|
|
|
|
} from './metadata';
|
2022-02-15 08:20:45 +00:00
|
|
|
import { NpmDatasource } from './npm';
|
2021-08-03 11:38:46 +00:00
|
|
|
import { PypiDatasource } from './pypi';
|
2021-08-10 11:24:32 +00:00
|
|
|
import type { ReleaseResult } from './types';
|
2019-07-22 07:58:35 +00:00
|
|
|
|
2022-03-03 09:35:26 +00:00
|
|
|
describe('modules/datasource/metadata', () => {
|
2019-07-22 07:58:35 +00:00
|
|
|
it('Should handle manualChangelogUrls', () => {
|
2021-08-10 11:24:32 +00:00
|
|
|
const dep: ReleaseResult = {
|
2019-07-22 07:58:35 +00:00
|
|
|
releases: [
|
2021-02-18 14:04:14 +00:00
|
|
|
{ version: '2.0.0', releaseTimestamp: '2018-07-13T10:14:17.000Z' },
|
2019-07-22 07:58:35 +00:00
|
|
|
{
|
|
|
|
version: '2.0.0.dev1',
|
2021-02-18 14:04:14 +00:00
|
|
|
releaseTimestamp: '2017-10-24T10:09:16.000Z',
|
2019-07-22 07:58:35 +00:00
|
|
|
},
|
2021-02-18 14:04:14 +00:00
|
|
|
{ version: '2.1.0', releaseTimestamp: '2019-01-20T19:59:28.000Z' },
|
|
|
|
{ version: '2.2.0', releaseTimestamp: '2019-07-16T18:29:00.000Z' },
|
2019-07-22 07:58:35 +00:00
|
|
|
],
|
|
|
|
};
|
|
|
|
|
2021-08-03 11:38:46 +00:00
|
|
|
const datasource = PypiDatasource.id;
|
2022-03-03 15:08:43 +00:00
|
|
|
const packageName = 'django';
|
2019-07-22 07:58:35 +00:00
|
|
|
|
2022-03-03 15:08:43 +00:00
|
|
|
addMetaData(dep, datasource, packageName);
|
2021-08-10 11:24:32 +00:00
|
|
|
expect(dep).toMatchSnapshot({
|
|
|
|
changelogUrl:
|
|
|
|
'https://github.com/django/django/tree/master/docs/releases',
|
|
|
|
});
|
2019-07-22 07:58:35 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Should handle manualSourceUrls', () => {
|
2021-08-10 11:24:32 +00:00
|
|
|
const dep: ReleaseResult = {
|
2019-07-22 07:58:35 +00:00
|
|
|
releases: [
|
2021-02-18 14:04:14 +00:00
|
|
|
{ version: '2.0.0', releaseTimestamp: '2018-07-13T10:14:17.000Z' },
|
2019-07-22 07:58:35 +00:00
|
|
|
{
|
|
|
|
version: '2.0.0.dev1',
|
2021-02-18 14:04:14 +00:00
|
|
|
releaseTimestamp: '2017-10-24T10:09:16.000Z',
|
2019-07-22 07:58:35 +00:00
|
|
|
},
|
2021-02-18 14:04:14 +00:00
|
|
|
{ version: '2.1.0', releaseTimestamp: '2019-01-20T19:59:28.000Z' },
|
|
|
|
{ version: '2.2.0', releaseTimestamp: '2019-07-16T18:29:00.000Z' },
|
2019-07-22 07:58:35 +00:00
|
|
|
],
|
|
|
|
};
|
|
|
|
|
2021-08-03 11:38:46 +00:00
|
|
|
const datasource = PypiDatasource.id;
|
2022-03-03 15:08:43 +00:00
|
|
|
const packageName = 'mkdocs';
|
2019-07-22 07:58:35 +00:00
|
|
|
|
2022-03-03 15:08:43 +00:00
|
|
|
addMetaData(dep, datasource, packageName);
|
2021-08-10 11:24:32 +00:00
|
|
|
expect(dep).toMatchSnapshot({
|
|
|
|
sourceUrl: 'https://github.com/mkdocs/mkdocs',
|
|
|
|
});
|
2019-07-22 07:58:35 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Should handle parsing of sourceUrls correctly', () => {
|
2021-08-10 11:24:32 +00:00
|
|
|
const dep: ReleaseResult = {
|
2019-07-22 07:58:35 +00:00
|
|
|
sourceUrl: 'https://github.com/carltongibson/django-filter/tree/master',
|
|
|
|
releases: [
|
2021-02-18 14:04:14 +00:00
|
|
|
{ version: '2.0.0', releaseTimestamp: '2018-07-13T10:14:17.000Z' },
|
2019-07-22 07:58:35 +00:00
|
|
|
{
|
|
|
|
version: '2.0.0.dev1',
|
2021-02-18 14:04:14 +00:00
|
|
|
releaseTimestamp: '2017-10-24T10:09:16.000Z',
|
2019-07-22 07:58:35 +00:00
|
|
|
},
|
2021-02-18 14:04:14 +00:00
|
|
|
{ version: '2.1.0', releaseTimestamp: '2019-01-20T19:59:28.000Z' },
|
|
|
|
{ version: '2.2.0', releaseTimestamp: '2019-07-16T18:29:00.000Z' },
|
2019-07-22 07:58:35 +00:00
|
|
|
],
|
|
|
|
};
|
2021-08-03 11:38:46 +00:00
|
|
|
const datasource = PypiDatasource.id;
|
2022-03-03 15:08:43 +00:00
|
|
|
const packageName = 'django-filter';
|
2019-07-22 07:58:35 +00:00
|
|
|
|
2022-03-03 15:08:43 +00:00
|
|
|
addMetaData(dep, datasource, packageName);
|
2021-08-10 11:24:32 +00:00
|
|
|
expect(dep).toMatchSnapshot({
|
|
|
|
sourceUrl: 'https://github.com/carltongibson/django-filter',
|
|
|
|
});
|
2019-07-22 07:58:35 +00:00
|
|
|
});
|
2019-07-31 17:24:57 +00:00
|
|
|
|
2021-11-18 14:50:53 +00:00
|
|
|
it('Should massage github sourceUrls', () => {
|
|
|
|
const dep: ReleaseResult = {
|
|
|
|
sourceUrl: 'https://some.github.com/repo',
|
|
|
|
releases: [
|
|
|
|
{ version: '2.0.0', releaseTimestamp: '2018-07-13T10:14:17.000Z' },
|
|
|
|
{
|
|
|
|
version: '2.0.0.dev1',
|
|
|
|
releaseTimestamp: '2017-10-24T10:09:16.000Z',
|
|
|
|
},
|
|
|
|
{ version: '2.1.0', releaseTimestamp: '2019-01-20T19:59:28.000Z' },
|
|
|
|
{ version: '2.2.0', releaseTimestamp: '2019-07-16T18:29:00.000Z' },
|
|
|
|
],
|
|
|
|
};
|
|
|
|
const datasource = PypiDatasource.id;
|
2022-03-03 15:08:43 +00:00
|
|
|
const packageName = 'django-filter';
|
2021-11-18 14:50:53 +00:00
|
|
|
|
2022-03-03 15:08:43 +00:00
|
|
|
addMetaData(dep, datasource, packageName);
|
2021-11-18 14:50:53 +00:00
|
|
|
expect(dep).toMatchSnapshot({
|
|
|
|
sourceUrl: 'https://github.com/some/repo',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-05-28 10:56:17 +00:00
|
|
|
it('Should handle parsing of sourceUrls correctly for GitLab also', () => {
|
2021-08-10 11:24:32 +00:00
|
|
|
const dep: ReleaseResult = {
|
2020-05-28 10:56:17 +00:00
|
|
|
sourceUrl: 'https://gitlab.com/meno/dropzone/tree/master',
|
|
|
|
releases: [
|
2021-02-18 14:04:14 +00:00
|
|
|
{ version: '5.7.0', releaseTimestamp: '2020-02-14T13:12:00.000Z' },
|
2020-05-28 10:56:17 +00:00
|
|
|
{
|
|
|
|
version: '5.6.1',
|
2021-02-18 14:04:14 +00:00
|
|
|
releaseTimestamp: '2020-02-14T10:04:00.000Z',
|
2020-05-28 10:56:17 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
2022-02-15 08:20:45 +00:00
|
|
|
const datasource = NpmDatasource.id;
|
2022-03-03 15:08:43 +00:00
|
|
|
const packageName = 'dropzone';
|
2020-05-28 10:56:17 +00:00
|
|
|
|
2022-03-03 15:08:43 +00:00
|
|
|
addMetaData(dep, datasource, packageName);
|
2021-08-10 11:24:32 +00:00
|
|
|
expect(dep).toMatchSnapshot({
|
|
|
|
sourceUrl: 'https://gitlab.com/meno/dropzone',
|
|
|
|
});
|
2020-05-28 10:56:17 +00:00
|
|
|
});
|
2022-04-12 14:49:49 +00:00
|
|
|
|
2020-05-28 11:17:22 +00:00
|
|
|
it('Should handle failed parsing of sourceUrls for GitLab', () => {
|
|
|
|
const dep = {
|
|
|
|
sourceUrl: 'https://gitlab-nope',
|
|
|
|
releases: [
|
2021-02-18 14:04:14 +00:00
|
|
|
{ version: '5.7.0', releaseTimestamp: '2020-02-14T13:12:00.000Z' },
|
2020-05-28 11:17:22 +00:00
|
|
|
{
|
|
|
|
version: '5.6.1',
|
2021-02-18 14:04:14 +00:00
|
|
|
releaseTimestamp: '2020-02-14T10:04:00.000Z',
|
2020-05-28 11:17:22 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
2022-02-15 08:20:45 +00:00
|
|
|
const datasource = NpmDatasource.id;
|
2022-03-03 15:08:43 +00:00
|
|
|
const packageName = 'dropzone';
|
2020-05-28 11:17:22 +00:00
|
|
|
|
2022-03-03 15:08:43 +00:00
|
|
|
addMetaData(dep, datasource, packageName);
|
2021-08-10 11:24:32 +00:00
|
|
|
expect(dep).toMatchSnapshot({
|
|
|
|
sourceUrl: 'https://gitlab-nope',
|
|
|
|
});
|
2020-05-28 11:17:22 +00:00
|
|
|
});
|
2022-04-12 14:49:49 +00:00
|
|
|
|
2020-05-28 11:17:22 +00:00
|
|
|
it('Should handle failed parsing of sourceUrls for other', () => {
|
|
|
|
const dep = {
|
|
|
|
sourceUrl: 'https://nope-nope-nope',
|
|
|
|
releases: [
|
2021-02-18 14:04:14 +00:00
|
|
|
{ version: '5.7.0', releaseTimestamp: '2020-02-14T13:12:00.000Z' },
|
2020-05-28 11:17:22 +00:00
|
|
|
{
|
|
|
|
version: '5.6.1',
|
2021-02-18 14:04:14 +00:00
|
|
|
releaseTimestamp: '2020-02-14T10:04:00.000Z',
|
2020-05-28 11:17:22 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
2022-02-15 08:20:45 +00:00
|
|
|
const datasource = NpmDatasource.id;
|
2022-03-03 15:08:43 +00:00
|
|
|
const packageName = 'dropzone';
|
2020-05-28 11:17:22 +00:00
|
|
|
|
2022-03-03 15:08:43 +00:00
|
|
|
addMetaData(dep, datasource, packageName);
|
2021-08-10 11:24:32 +00:00
|
|
|
expect(dep).toMatchSnapshot({
|
|
|
|
sourceUrl: 'https://nope-nope-nope',
|
|
|
|
});
|
2020-05-28 11:17:22 +00:00
|
|
|
});
|
2022-04-12 14:49:49 +00:00
|
|
|
|
2020-05-28 12:29:54 +00:00
|
|
|
it('Should handle non-url', () => {
|
|
|
|
const dep = {
|
|
|
|
sourceUrl: 'not-a-url',
|
|
|
|
releases: [
|
2021-02-18 14:04:14 +00:00
|
|
|
{ version: '5.7.0', releaseTimestamp: '2020-02-14T13:12:00.000Z' },
|
2020-05-28 12:29:54 +00:00
|
|
|
{
|
|
|
|
version: '5.6.1',
|
2021-02-18 14:04:14 +00:00
|
|
|
releaseTimestamp: '2020-02-14T10:04:00.000Z',
|
2020-05-28 12:29:54 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
2022-02-15 08:20:45 +00:00
|
|
|
const datasource = NpmDatasource.id;
|
2022-03-03 15:08:43 +00:00
|
|
|
const packageName = 'dropzone';
|
2020-05-28 12:29:54 +00:00
|
|
|
|
2022-03-03 15:08:43 +00:00
|
|
|
addMetaData(dep, datasource, packageName);
|
2021-08-10 11:24:32 +00:00
|
|
|
expect(dep).not.toContainKey('sourceUrl');
|
2020-05-28 12:29:54 +00:00
|
|
|
expect(dep).toMatchSnapshot();
|
|
|
|
});
|
2020-05-28 10:56:17 +00:00
|
|
|
|
2019-07-31 17:24:57 +00:00
|
|
|
it('Should handle parsing/converting of GitHub sourceUrls with http and www correctly', () => {
|
|
|
|
const dep = {
|
|
|
|
sourceUrl: 'http://www.github.com/mockk/mockk/',
|
|
|
|
releases: [{ version: '1.9.3' }],
|
|
|
|
};
|
2022-02-15 05:12:30 +00:00
|
|
|
const datasource = MavenDatasource.id;
|
2022-03-03 15:08:43 +00:00
|
|
|
const packageName = 'io.mockk:mockk';
|
2019-07-31 17:24:57 +00:00
|
|
|
|
2022-03-03 15:08:43 +00:00
|
|
|
addMetaData(dep, datasource, packageName);
|
2021-11-08 12:16:58 +00:00
|
|
|
expect(dep.sourceUrl).toBe('https://github.com/mockk/mockk');
|
2019-07-31 17:24:57 +00:00
|
|
|
});
|
2020-05-28 10:56:17 +00:00
|
|
|
|
|
|
|
it('Should move github homepage to sourceUrl', () => {
|
|
|
|
const dep = {
|
|
|
|
homepage: 'http://www.github.com/mockk/mockk/',
|
|
|
|
releases: [{ version: '1.9.3' }],
|
|
|
|
sourceUrl: undefined,
|
|
|
|
};
|
2022-02-15 05:12:30 +00:00
|
|
|
const datasource = MavenDatasource.id;
|
2022-03-03 15:08:43 +00:00
|
|
|
const packageName = 'io.mockk:mockk';
|
2020-05-28 10:56:17 +00:00
|
|
|
|
2022-03-03 15:08:43 +00:00
|
|
|
addMetaData(dep, datasource, packageName);
|
2021-11-08 12:16:58 +00:00
|
|
|
expect(dep.sourceUrl).toBe('https://github.com/mockk/mockk');
|
2020-05-28 10:56:17 +00:00
|
|
|
expect(dep.homepage).toBeUndefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should handle parsing/converting of GitLab sourceUrls with http and www correctly', () => {
|
|
|
|
const dep = {
|
|
|
|
sourceUrl: 'http://gitlab.com/meno/dropzone/',
|
|
|
|
releases: [{ version: '5.7.0' }],
|
|
|
|
};
|
2022-02-15 05:12:30 +00:00
|
|
|
const datasource = MavenDatasource.id;
|
2022-03-03 15:08:43 +00:00
|
|
|
const packageName = 'dropzone';
|
2020-05-28 10:56:17 +00:00
|
|
|
|
2022-03-03 15:08:43 +00:00
|
|
|
addMetaData(dep, datasource, packageName);
|
2021-11-08 12:16:58 +00:00
|
|
|
expect(dep.sourceUrl).toBe('https://gitlab.com/meno/dropzone');
|
2020-05-28 10:56:17 +00:00
|
|
|
});
|
2021-02-18 14:04:14 +00:00
|
|
|
|
|
|
|
it('Should normalize releaseTimestamp', () => {
|
|
|
|
const dep = {
|
|
|
|
releases: [
|
|
|
|
{ version: '1.0.1', releaseTimestamp: '2000-01-01T12:34:56' },
|
|
|
|
{ version: '1.0.2', releaseTimestamp: '2000-01-02T12:34:56.000Z' },
|
|
|
|
{ version: '1.0.3', releaseTimestamp: '2000-01-03T14:34:56.000+02:00' },
|
|
|
|
],
|
|
|
|
};
|
2022-02-15 05:12:30 +00:00
|
|
|
addMetaData(dep, MavenDatasource.id, 'foobar');
|
2021-02-18 14:04:14 +00:00
|
|
|
expect(dep.releases).toMatchObject([
|
|
|
|
{ releaseTimestamp: '2000-01-01T12:34:56.000Z' },
|
|
|
|
{ releaseTimestamp: '2000-01-02T12:34:56.000Z' },
|
|
|
|
{ releaseTimestamp: '2000-01-03T12:34:56.000Z' },
|
|
|
|
]);
|
|
|
|
});
|
2021-12-01 07:47:16 +00:00
|
|
|
|
|
|
|
it('Should massage github git@ url to valid https url', () => {
|
|
|
|
expect(massageGithubUrl('git@example.com:foo/bar')).toMatch(
|
|
|
|
'https://example.com/foo/bar'
|
|
|
|
);
|
|
|
|
});
|
2022-04-12 14:49:49 +00:00
|
|
|
|
2021-12-01 07:47:16 +00:00
|
|
|
it('Should massage github http url to valid https url', () => {
|
|
|
|
expect(massageGithubUrl('http://example.com/foo/bar')).toMatch(
|
|
|
|
'https://example.com/foo/bar'
|
|
|
|
);
|
|
|
|
});
|
2022-04-12 14:49:49 +00:00
|
|
|
|
2021-12-01 07:47:16 +00:00
|
|
|
it('Should massage github http and git url to valid https url', () => {
|
|
|
|
expect(massageGithubUrl('http+git://example.com/foo/bar')).toMatch(
|
|
|
|
'https://example.com/foo/bar'
|
|
|
|
);
|
|
|
|
});
|
2022-04-12 14:49:49 +00:00
|
|
|
|
2021-12-01 07:47:16 +00:00
|
|
|
it('Should massage github ssh git@ url to valid https url', () => {
|
|
|
|
expect(massageGithubUrl('ssh://git@example.com/foo/bar')).toMatch(
|
|
|
|
'https://example.com/foo/bar'
|
|
|
|
);
|
|
|
|
});
|
2022-04-12 14:49:49 +00:00
|
|
|
|
2021-12-01 07:47:16 +00:00
|
|
|
it('Should massage github git url to valid https url', () => {
|
|
|
|
expect(massageGithubUrl('git://example.com/foo/bar')).toMatch(
|
|
|
|
'https://example.com/foo/bar'
|
|
|
|
);
|
|
|
|
});
|
2022-08-25 17:18:51 +00:00
|
|
|
|
|
|
|
it('Should remove homepage when homepage and sourceUrl are same', () => {
|
|
|
|
const dep = {
|
|
|
|
homepage: 'https://github.com/foo/bar',
|
|
|
|
sourceUrl: 'https://github.com/foo/bar',
|
|
|
|
releases: [
|
|
|
|
{ version: '1.0.1', releaseTimestamp: '2000-01-01T12:34:56' },
|
|
|
|
{ version: '1.0.2', releaseTimestamp: '2000-01-02T12:34:56.000Z' },
|
|
|
|
{ version: '1.0.3', releaseTimestamp: '2000-01-03T14:34:56.000+02:00' },
|
|
|
|
],
|
|
|
|
};
|
|
|
|
addMetaData(dep, MavenDatasource.id, 'foobar');
|
|
|
|
expect(dep).toMatchObject({
|
|
|
|
releases: [
|
|
|
|
{
|
|
|
|
version: '1.0.1',
|
|
|
|
releaseTimestamp: '2000-01-01T12:34:56.000Z',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
version: '1.0.2',
|
|
|
|
releaseTimestamp: '2000-01-02T12:34:56.000Z',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
version: '1.0.3',
|
|
|
|
releaseTimestamp: '2000-01-03T12:34:56.000Z',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
sourceUrl: 'https://github.com/foo/bar',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should delete gitlab homepage if its same as sourceUrl', () => {
|
|
|
|
const dep = {
|
|
|
|
sourceUrl: 'https://gitlab.com/meno/repo',
|
|
|
|
homepage: 'https://gitlab.com/meno/repo',
|
|
|
|
releases: [
|
|
|
|
{ version: '1.0.1', releaseTimestamp: '2000-01-01T12:34:56' },
|
|
|
|
{ version: '1.0.2', releaseTimestamp: '2000-01-02T12:34:56.000Z' },
|
|
|
|
{ version: '1.0.3', releaseTimestamp: '2000-01-03T14:34:56.000+02:00' },
|
|
|
|
],
|
|
|
|
};
|
|
|
|
addMetaData(dep, MavenDatasource.id, 'foobar');
|
|
|
|
expect(dep).toMatchObject({
|
|
|
|
sourceUrl: 'https://gitlab.com/meno/repo',
|
|
|
|
releases: [
|
|
|
|
{
|
|
|
|
version: '1.0.1',
|
|
|
|
releaseTimestamp: '2000-01-01T12:34:56.000Z',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
version: '1.0.2',
|
|
|
|
releaseTimestamp: '2000-01-02T12:34:56.000Z',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
version: '1.0.3',
|
|
|
|
releaseTimestamp: '2000-01-03T12:34:56.000Z',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not set homepage to sourceURl when undefined', () => {
|
|
|
|
const dep = {
|
|
|
|
sourceUrl: 'https://gitlab.com/meno/repo',
|
|
|
|
releases: [
|
|
|
|
{ version: '1.0.1', releaseTimestamp: '2000-01-01T12:34:56' },
|
|
|
|
{ version: '1.0.2', releaseTimestamp: '2000-01-02T12:34:56.000Z' },
|
|
|
|
{ version: '1.0.3', releaseTimestamp: '2000-01-03T14:34:56.000+02:00' },
|
|
|
|
],
|
|
|
|
};
|
|
|
|
addMetaData(dep, MavenDatasource.id, 'foobar');
|
|
|
|
expect(dep).toMatchObject({
|
|
|
|
sourceUrl: 'https://gitlab.com/meno/repo',
|
|
|
|
releases: [
|
|
|
|
{
|
|
|
|
version: '1.0.1',
|
|
|
|
releaseTimestamp: '2000-01-01T12:34:56.000Z',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
version: '1.0.2',
|
|
|
|
releaseTimestamp: '2000-01-02T12:34:56.000Z',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
version: '1.0.3',
|
|
|
|
releaseTimestamp: '2000-01-03T12:34:56.000Z',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not set homepage to sourceURl when not github or gitlab', () => {
|
|
|
|
const dep = {
|
|
|
|
homepage: 'https://somesource.com/',
|
|
|
|
releases: [
|
|
|
|
{ version: '1.0.1', releaseTimestamp: '2000-01-01T12:34:56' },
|
|
|
|
{ version: '1.0.2', releaseTimestamp: '2000-01-02T12:34:56.000Z' },
|
|
|
|
{ version: '1.0.3', releaseTimestamp: '2000-01-03T14:34:56.000+02:00' },
|
|
|
|
],
|
|
|
|
};
|
|
|
|
addMetaData(dep, MavenDatasource.id, 'foobar');
|
|
|
|
expect(dep).toMatchObject({
|
|
|
|
homepage: 'https://somesource.com/',
|
|
|
|
releases: [
|
|
|
|
{
|
|
|
|
version: '1.0.1',
|
|
|
|
releaseTimestamp: '2000-01-01T12:34:56.000Z',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
version: '1.0.2',
|
|
|
|
releaseTimestamp: '2000-01-02T12:34:56.000Z',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
version: '1.0.3',
|
|
|
|
releaseTimestamp: '2000-01-03T12:34:56.000Z',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test.each`
|
|
|
|
sourceUrl | homepage | expected
|
|
|
|
${'not a url'} | ${'https://gitlab.com/org/repo'} | ${false}
|
|
|
|
${'https://gitlab.com/org/repo'} | ${'not a url'} | ${false}
|
|
|
|
${'https://gitlab.com/org'} | ${'https://gitlab.com/org/'} | ${true}
|
|
|
|
${'https://gitlab.com/org/repo/'} | ${'https://gitlab.com/org/repo'} | ${true}
|
|
|
|
${'https://github.com/org/repo/path/'} | ${'https://github.com/org/repo/path/'} | ${false}
|
|
|
|
${'https://gitlab.com/org/repo/'} | ${'https://gitlab.com/org/repo/path/to/something/'} | ${false}
|
|
|
|
${'https://gitlab.com/org/repo/'} | ${null} | ${false}
|
|
|
|
${'https://gitlab.com/org/repo/'} | ${undefined} | ${false}
|
|
|
|
${'https://gitlab.com/org/repo/'} | ${'github.com'} | ${false}
|
|
|
|
${'https://github.com/bitnami/charts'} | ${'https://github.com/bitnami/charts/tree/master/bitnami/kube-prometheus'} | ${false}
|
|
|
|
`(
|
|
|
|
'shouldDeleteHomepage($sourceUrl, $homepage) -> $expected',
|
|
|
|
({ sourceUrl, homepage, expected }) => {
|
|
|
|
expect(shouldDeleteHomepage(sourceUrl, homepage)).toBe(expected);
|
|
|
|
}
|
|
|
|
);
|
2019-07-22 07:58:35 +00:00
|
|
|
});
|