2019-08-15 04:30:16 +00:00
|
|
|
import fs from 'fs';
|
2020-06-18 19:31:40 +00:00
|
|
|
import { getPkgReleases } from '..';
|
2020-06-16 05:11:21 +00:00
|
|
|
import * as httpMock from '../../../test/httpMock';
|
2020-02-11 05:08:10 +00:00
|
|
|
import * as _hostRules from '../../util/host-rules';
|
2020-06-18 19:31:40 +00:00
|
|
|
import { id as versioning } from '../../versioning/nuget';
|
|
|
|
import { id as datasource } from '.';
|
2019-12-20 08:27:58 +00:00
|
|
|
|
|
|
|
const hostRules: any = _hostRules;
|
2018-06-14 09:15:52 +00:00
|
|
|
|
2020-02-11 05:08:10 +00:00
|
|
|
jest.mock('../../util/host-rules');
|
2018-06-14 09:15:52 +00:00
|
|
|
|
2019-03-11 15:50:10 +00:00
|
|
|
const pkgListV3 = fs.readFileSync(
|
2020-02-11 05:08:10 +00:00
|
|
|
'lib/datasource/nuget/__fixtures__/nunitV3.json',
|
2019-03-11 15:50:10 +00:00
|
|
|
'utf8'
|
|
|
|
);
|
2019-02-19 14:58:42 +00:00
|
|
|
const pkgListV3WithoutProkjectUrl = fs.readFileSync(
|
2020-02-11 05:08:10 +00:00
|
|
|
'lib/datasource/nuget/__fixtures__/nunitV3_withoutProjectUrl.json',
|
2019-02-19 14:58:42 +00:00
|
|
|
'utf8'
|
|
|
|
);
|
2019-11-13 09:58:33 +00:00
|
|
|
const pkgListV3NoGitHubProjectUrl = fs.readFileSync(
|
2020-02-11 05:08:10 +00:00
|
|
|
'lib/datasource/nuget/__fixtures__/nunitV3_noGitHubProjectUrl.json',
|
2019-11-13 09:58:33 +00:00
|
|
|
'utf8'
|
|
|
|
);
|
2020-05-15 04:46:31 +00:00
|
|
|
const pkgListV3PrivateFeed = fs.readFileSync(
|
|
|
|
'lib/datasource/nuget/__fixtures__/nunitV3_privateFeed.json',
|
|
|
|
'utf8'
|
|
|
|
);
|
2019-02-19 14:58:42 +00:00
|
|
|
const pkgInfoV3FromNuget = fs.readFileSync(
|
2020-02-11 05:08:10 +00:00
|
|
|
'lib/datasource/nuget/__fixtures__/nunitv3_nuget-org.xml',
|
2019-02-19 14:58:42 +00:00
|
|
|
'utf8'
|
|
|
|
);
|
|
|
|
|
2019-03-11 15:50:10 +00:00
|
|
|
const pkgListV2 = fs.readFileSync(
|
2020-02-11 05:08:10 +00:00
|
|
|
'lib/datasource/nuget/__fixtures__/nunitV2.xml',
|
2019-03-11 15:50:10 +00:00
|
|
|
'utf8'
|
|
|
|
);
|
2019-11-13 09:58:33 +00:00
|
|
|
const pkgListV2NoGitHubProjectUrl = fs.readFileSync(
|
2020-02-11 05:08:10 +00:00
|
|
|
'lib/datasource/nuget/__fixtures__/nunitV2_noGitHubProjectUrl.xml',
|
2019-11-13 09:58:33 +00:00
|
|
|
'utf8'
|
|
|
|
);
|
2019-09-17 10:55:22 +00:00
|
|
|
const pkgListV2NoRelease = fs.readFileSync(
|
2020-02-11 05:08:10 +00:00
|
|
|
'lib/datasource/nuget/__fixtures__/nunitV2_no_release.xml',
|
2019-09-17 10:55:22 +00:00
|
|
|
'utf8'
|
|
|
|
);
|
2019-02-22 09:34:01 +00:00
|
|
|
const pkgListV2WithoutProjectUrl = fs.readFileSync(
|
2020-02-11 05:08:10 +00:00
|
|
|
'lib/datasource/nuget/__fixtures__/nunitV2_withoutProjectUrl.xml',
|
2019-02-19 14:58:42 +00:00
|
|
|
'utf8'
|
|
|
|
);
|
|
|
|
|
2019-04-29 20:16:47 +00:00
|
|
|
const pkgListV2Page1of2 = fs.readFileSync(
|
2020-02-11 05:08:10 +00:00
|
|
|
'lib/datasource/nuget/__fixtures__/nunitV2_paginated_1.xml',
|
2019-04-29 20:16:47 +00:00
|
|
|
'utf8'
|
|
|
|
);
|
|
|
|
const pkgListV2Page2of2 = fs.readFileSync(
|
2020-02-11 05:08:10 +00:00
|
|
|
'lib/datasource/nuget/__fixtures__/nunitV2_paginated_2.xml',
|
2019-04-29 20:16:47 +00:00
|
|
|
'utf8'
|
|
|
|
);
|
|
|
|
|
2019-02-19 14:58:42 +00:00
|
|
|
const nugetIndexV3 = fs.readFileSync(
|
2020-02-11 05:08:10 +00:00
|
|
|
'lib/datasource/nuget/__fixtures__/indexV3.json',
|
2019-02-19 14:58:42 +00:00
|
|
|
'utf8'
|
|
|
|
);
|
|
|
|
|
|
|
|
const configV3V2 = {
|
2020-06-18 19:31:40 +00:00
|
|
|
datasource,
|
|
|
|
versioning,
|
|
|
|
depName: 'nunit',
|
2019-02-19 14:58:42 +00:00
|
|
|
registryUrls: [
|
|
|
|
'https://api.nuget.org/v3/index.json',
|
|
|
|
'https://www.nuget.org/api/v2/',
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
const configV2 = {
|
2020-06-18 19:31:40 +00:00
|
|
|
datasource,
|
|
|
|
versioning,
|
|
|
|
depName: 'nunit',
|
2019-02-19 14:58:42 +00:00
|
|
|
registryUrls: ['https://www.nuget.org/api/v2/'],
|
|
|
|
};
|
|
|
|
|
|
|
|
const configV3 = {
|
2020-06-18 19:31:40 +00:00
|
|
|
datasource,
|
|
|
|
versioning,
|
|
|
|
depName: 'nunit',
|
2019-02-19 14:58:42 +00:00
|
|
|
registryUrls: ['https://api.nuget.org/v3/index.json'],
|
|
|
|
};
|
|
|
|
|
|
|
|
const configV3NotNugetOrg = {
|
2020-06-18 19:31:40 +00:00
|
|
|
datasource,
|
|
|
|
versioning,
|
|
|
|
depName: 'nunit',
|
2019-02-19 14:58:42 +00:00
|
|
|
registryUrls: ['https://myprivatefeed/index.json'],
|
|
|
|
};
|
2018-06-14 09:15:52 +00:00
|
|
|
|
2020-05-15 04:46:31 +00:00
|
|
|
const configV3Multiple = {
|
2020-06-18 19:31:40 +00:00
|
|
|
datasource,
|
|
|
|
versioning,
|
|
|
|
depName: 'nunit',
|
2020-05-15 04:46:31 +00:00
|
|
|
registryUrls: [
|
|
|
|
'https://api.nuget.org/v3/index.json',
|
|
|
|
'https://myprivatefeed/index.json',
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
2018-06-14 13:52:37 +00:00
|
|
|
describe('datasource/nuget', () => {
|
2020-04-04 06:53:52 +00:00
|
|
|
describe('getReleases', () => {
|
2018-12-25 11:31:51 +00:00
|
|
|
beforeEach(() => {
|
2019-02-22 09:34:01 +00:00
|
|
|
jest.resetAllMocks();
|
2019-12-20 08:27:58 +00:00
|
|
|
hostRules.hosts = jest.fn(() => []);
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock.setup();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
httpMock.reset();
|
2018-12-25 11:31:51 +00:00
|
|
|
});
|
2019-02-19 14:58:42 +00:00
|
|
|
|
|
|
|
it(`can't detect nuget feed version`, async () => {
|
|
|
|
const config = {
|
2020-06-18 19:31:40 +00:00
|
|
|
datasource,
|
|
|
|
versioning,
|
|
|
|
depName: 'nunit',
|
2019-02-19 14:58:42 +00:00
|
|
|
registryUrls: ['#$#api.nuget.org/v3/index.xml'],
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(
|
2020-06-18 19:31:40 +00:00
|
|
|
await getPkgReleases({
|
2019-02-19 14:58:42 +00:00
|
|
|
...config,
|
|
|
|
})
|
|
|
|
).toBeNull();
|
|
|
|
});
|
|
|
|
|
2020-03-19 20:58:37 +00:00
|
|
|
it('extracts feed version from registry URL hash', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock.scope('https://my-registry').get('/').reply(200);
|
2020-03-19 20:58:37 +00:00
|
|
|
const config = {
|
2020-06-18 19:31:40 +00:00
|
|
|
datasource,
|
|
|
|
versioning,
|
|
|
|
depName: 'nunit',
|
2020-03-19 20:58:37 +00:00
|
|
|
registryUrls: ['https://my-registry#protocolVersion=3'],
|
|
|
|
};
|
2020-06-18 19:31:40 +00:00
|
|
|
await getPkgReleases({
|
2020-03-19 20:58:37 +00:00
|
|
|
...config,
|
|
|
|
});
|
2020-06-16 05:11:21 +00:00
|
|
|
const trace = httpMock.getTrace();
|
|
|
|
expect(trace[0].url).toEqual('https://my-registry/');
|
|
|
|
expect(trace).toMatchSnapshot();
|
2020-03-19 20:58:37 +00:00
|
|
|
});
|
|
|
|
|
2019-02-19 14:58:42 +00:00
|
|
|
it(`can't get packages list (v3)`, async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://api.nuget.org')
|
|
|
|
.get('/v3/index.json')
|
|
|
|
.reply(200, JSON.parse(nugetIndexV3));
|
|
|
|
httpMock
|
|
|
|
.scope('https://api-v2v3search-0.nuget.org')
|
|
|
|
.get('/query?q=PackageId:nunit&semVerLevel=2.0.0&prerelease=true')
|
|
|
|
.reply(500);
|
|
|
|
|
2020-06-18 19:31:40 +00:00
|
|
|
const res = await getPkgReleases({
|
2019-02-19 14:58:42 +00:00
|
|
|
...configV3,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(res).toBeNull();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-02-19 14:58:42 +00:00
|
|
|
});
|
|
|
|
it(`empty packages list (v3)`, async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://api.nuget.org')
|
|
|
|
.get('/v3/index.json')
|
|
|
|
.reply(200, JSON.parse(nugetIndexV3));
|
|
|
|
httpMock
|
|
|
|
.scope('https://api-v2v3search-0.nuget.org')
|
|
|
|
.get('/query?q=PackageId:nunit&semVerLevel=2.0.0&prerelease=true')
|
|
|
|
.reply(200, JSON.parse('{"totalHits": 0}'));
|
|
|
|
|
2020-06-18 19:31:40 +00:00
|
|
|
const res = await getPkgReleases({
|
2019-02-19 14:58:42 +00:00
|
|
|
...configV3,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(res).toBeNull();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-02-19 14:58:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('returns null for empty result (v3v2)', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://api.nuget.org')
|
|
|
|
.get('/v3/index.json')
|
|
|
|
.reply(200, {});
|
|
|
|
httpMock
|
|
|
|
.scope('https://www.nuget.org')
|
|
|
|
.get(
|
|
|
|
'/api/v2//FindPackagesById()?id=%27nunit%27&$select=Version,IsLatestVersion,ProjectUrl'
|
|
|
|
)
|
|
|
|
.reply(200, null);
|
2019-02-19 14:58:42 +00:00
|
|
|
expect(
|
2020-06-18 19:31:40 +00:00
|
|
|
await getPkgReleases({
|
2019-02-19 14:58:42 +00:00
|
|
|
...configV3V2,
|
|
|
|
})
|
|
|
|
).toBeNull();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-02-19 14:58:42 +00:00
|
|
|
});
|
|
|
|
it('returns null for empty result (v2)', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://www.nuget.org')
|
|
|
|
.get(
|
|
|
|
'/api/v2//FindPackagesById()?id=%27nunit%27&$select=Version,IsLatestVersion,ProjectUrl'
|
|
|
|
)
|
|
|
|
.reply(200, {});
|
2019-02-19 14:58:42 +00:00
|
|
|
expect(
|
2020-06-18 19:31:40 +00:00
|
|
|
await getPkgReleases({
|
2019-02-19 14:58:42 +00:00
|
|
|
...configV2,
|
|
|
|
})
|
|
|
|
).toBeNull();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-02-19 14:58:42 +00:00
|
|
|
});
|
|
|
|
it('returns null for empty result (v3)', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://api.nuget.org')
|
|
|
|
.get('/v3/index.json')
|
|
|
|
.reply(200, {});
|
2020-06-18 19:31:40 +00:00
|
|
|
const res = await getPkgReleases({
|
2020-06-16 05:11:21 +00:00
|
|
|
...configV3,
|
|
|
|
});
|
|
|
|
expect(res).toBeNull();
|
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-02-19 14:58:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('returns null for non 200 (v3v2)', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock.scope('https://api.nuget.org').get('/v3/index.json').reply(500);
|
|
|
|
httpMock
|
|
|
|
.scope('https://www.nuget.org')
|
|
|
|
.get(
|
|
|
|
'/api/v2//FindPackagesById()?id=%27nunit%27&$select=Version,IsLatestVersion,ProjectUrl'
|
|
|
|
)
|
|
|
|
.reply(500);
|
2019-02-19 14:58:42 +00:00
|
|
|
expect(
|
2020-06-18 19:31:40 +00:00
|
|
|
await getPkgReleases({
|
2019-02-19 14:58:42 +00:00
|
|
|
...configV3V2,
|
|
|
|
})
|
|
|
|
).toBeNull();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-02-19 14:58:42 +00:00
|
|
|
});
|
|
|
|
it('returns null for non 200 (v3)', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock.scope('https://api.nuget.org').get('/v3/index.json').reply(500);
|
2019-02-19 14:58:42 +00:00
|
|
|
expect(
|
2020-06-18 19:31:40 +00:00
|
|
|
await getPkgReleases({
|
2019-02-19 14:58:42 +00:00
|
|
|
...configV3,
|
2019-02-04 08:41:22 +00:00
|
|
|
})
|
2019-01-28 05:40:37 +00:00
|
|
|
).toBeNull();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2018-06-14 09:15:52 +00:00
|
|
|
});
|
2020-05-18 12:33:44 +00:00
|
|
|
it('returns null for non 200 (v2)', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://www.nuget.org')
|
|
|
|
.get(
|
|
|
|
'/api/v2//FindPackagesById()?id=%27nunit%27&$select=Version,IsLatestVersion,ProjectUrl'
|
|
|
|
)
|
|
|
|
.reply(500);
|
2019-01-28 05:40:37 +00:00
|
|
|
expect(
|
2020-06-18 19:31:40 +00:00
|
|
|
await getPkgReleases({
|
2019-02-19 14:58:42 +00:00
|
|
|
...configV2,
|
|
|
|
})
|
|
|
|
).toBeNull();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-02-19 14:58:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('returns null for unknown error (v3v2)', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://api.nuget.org')
|
|
|
|
.get('/v3/index.json')
|
|
|
|
.replyWithError('');
|
|
|
|
httpMock
|
|
|
|
.scope('https://www.nuget.org')
|
|
|
|
.get(
|
|
|
|
'/api/v2//FindPackagesById()?id=%27nunit%27&$select=Version,IsLatestVersion,ProjectUrl'
|
|
|
|
)
|
|
|
|
.replyWithError('');
|
2019-02-19 14:58:42 +00:00
|
|
|
expect(
|
2020-06-18 19:31:40 +00:00
|
|
|
await getPkgReleases({
|
2019-02-19 14:58:42 +00:00
|
|
|
...configV3V2,
|
|
|
|
})
|
|
|
|
).toBeNull();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-02-19 14:58:42 +00:00
|
|
|
});
|
2020-05-15 04:46:31 +00:00
|
|
|
it('returns deduplicated results', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://api.nuget.org')
|
|
|
|
.get('/v3/index.json')
|
|
|
|
.reply(200, JSON.parse(nugetIndexV3))
|
|
|
|
.get('/v3-flatcontainer/nunit/3.11.0/nunit.nuspec')
|
|
|
|
.reply(200, pkgInfoV3FromNuget);
|
|
|
|
httpMock
|
|
|
|
.scope('https://api-v2v3search-0.nuget.org')
|
|
|
|
.get('/query?q=PackageId:nunit&semVerLevel=2.0.0&prerelease=true')
|
|
|
|
.reply(200, JSON.parse(pkgListV3))
|
|
|
|
.get('/query?q=nunit')
|
|
|
|
.reply(200, JSON.parse(pkgListV3PrivateFeed));
|
|
|
|
httpMock
|
|
|
|
.scope('https://myprivatefeed')
|
|
|
|
.get('/index.json')
|
|
|
|
.reply(200, JSON.parse(nugetIndexV3));
|
|
|
|
|
2020-06-18 19:31:40 +00:00
|
|
|
const res = await getPkgReleases({
|
2020-05-15 04:46:31 +00:00
|
|
|
...configV3Multiple,
|
|
|
|
});
|
|
|
|
expect(res).not.toBeNull();
|
|
|
|
expect(res).toMatchSnapshot();
|
|
|
|
expect(res.releases).toHaveLength(30);
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2020-05-15 04:46:31 +00:00
|
|
|
});
|
2020-04-04 06:53:52 +00:00
|
|
|
it('returns null for unknown error in getReleasesFromV3Feed (v3)', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://api.nuget.org')
|
|
|
|
.get('/v3/index.json')
|
|
|
|
.replyWithError('');
|
2019-02-19 14:58:42 +00:00
|
|
|
expect(
|
2020-06-18 19:31:40 +00:00
|
|
|
await getPkgReleases({
|
2019-02-19 14:58:42 +00:00
|
|
|
...configV3,
|
|
|
|
})
|
|
|
|
).toBeNull();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-02-19 14:58:42 +00:00
|
|
|
});
|
|
|
|
it('returns null for unknown error in getQueryUrlForV3Feed (v3)', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://api.nuget.org')
|
|
|
|
.get('/v3/index.json')
|
|
|
|
.reply(200, JSON.parse(nugetIndexV3));
|
|
|
|
httpMock
|
|
|
|
.scope('https://api-v2v3search-0.nuget.org')
|
|
|
|
.get('/query?q=PackageId:nunit&semVerLevel=2.0.0&prerelease=true')
|
|
|
|
.replyWithError('');
|
2019-02-19 14:58:42 +00:00
|
|
|
expect(
|
2020-06-18 19:31:40 +00:00
|
|
|
await getPkgReleases({
|
2019-02-19 14:58:42 +00:00
|
|
|
...configV3,
|
2019-02-04 08:41:22 +00:00
|
|
|
})
|
2019-01-28 05:40:37 +00:00
|
|
|
).toBeNull();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2018-06-14 13:52:37 +00:00
|
|
|
});
|
2019-02-19 14:58:42 +00:00
|
|
|
it('returns null for unknown error (v2)', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://www.nuget.org')
|
|
|
|
.get(
|
|
|
|
'/api/v2//FindPackagesById()?id=%27nunit%27&$select=Version,IsLatestVersion,ProjectUrl'
|
|
|
|
)
|
|
|
|
.replyWithError('');
|
2019-01-28 05:40:37 +00:00
|
|
|
expect(
|
2020-06-18 19:31:40 +00:00
|
|
|
await getPkgReleases({
|
2019-02-19 14:58:42 +00:00
|
|
|
...configV2,
|
2019-02-04 08:41:22 +00:00
|
|
|
})
|
2019-01-28 05:40:37 +00:00
|
|
|
).toBeNull();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2018-06-14 13:52:37 +00:00
|
|
|
});
|
2019-02-19 14:58:42 +00:00
|
|
|
it('processes real data (v3) feed is a nuget.org', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://api.nuget.org')
|
|
|
|
.get('/v3/index.json')
|
|
|
|
.reply(200, JSON.parse(nugetIndexV3))
|
|
|
|
.get('/v3-flatcontainer/nunit/3.11.0/nunit.nuspec')
|
|
|
|
.reply(200, pkgInfoV3FromNuget);
|
|
|
|
httpMock
|
|
|
|
.scope('https://api-v2v3search-0.nuget.org')
|
|
|
|
.get('/query?q=PackageId:nunit&semVerLevel=2.0.0&prerelease=true')
|
|
|
|
.reply(200, JSON.parse(pkgListV3));
|
2020-06-18 19:31:40 +00:00
|
|
|
const res = await getPkgReleases({
|
2019-02-19 14:58:42 +00:00
|
|
|
...configV3,
|
|
|
|
});
|
|
|
|
expect(res).not.toBeNull();
|
|
|
|
expect(res).toMatchSnapshot();
|
|
|
|
expect(res.sourceUrl).toBeDefined();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-02-19 14:58:42 +00:00
|
|
|
});
|
|
|
|
it('processes real data (v3) feed is not a nuget.org', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://api-v2v3search-0.nuget.org')
|
|
|
|
.get('/query?q=nunit')
|
|
|
|
.reply(200, JSON.parse(pkgListV3));
|
|
|
|
httpMock
|
|
|
|
.scope('https://myprivatefeed')
|
|
|
|
.get('/index.json')
|
|
|
|
.reply(200, JSON.parse(nugetIndexV3));
|
|
|
|
|
2020-06-18 19:31:40 +00:00
|
|
|
const res = await getPkgReleases({
|
2019-02-19 14:58:42 +00:00
|
|
|
...configV3NotNugetOrg,
|
|
|
|
});
|
|
|
|
expect(res).not.toBeNull();
|
|
|
|
expect(res).toMatchSnapshot();
|
|
|
|
expect(res.sourceUrl).toBeDefined();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-02-19 14:58:42 +00:00
|
|
|
});
|
2019-04-25 10:28:40 +00:00
|
|
|
it('processes real data (v3) feed is not a nuget.org with mismatch', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://api-v2v3search-0.nuget.org')
|
|
|
|
.get('/query?q=nun')
|
|
|
|
.reply(200, JSON.parse(pkgListV3));
|
|
|
|
httpMock
|
|
|
|
.scope('https://myprivatefeed')
|
|
|
|
.get('/index.json')
|
|
|
|
.reply(200, JSON.parse(nugetIndexV3));
|
2020-06-18 19:31:40 +00:00
|
|
|
const res = await getPkgReleases({
|
2019-04-25 10:28:40 +00:00
|
|
|
...configV3NotNugetOrg,
|
2020-06-18 19:31:40 +00:00
|
|
|
datasource,
|
|
|
|
versioning,
|
|
|
|
depName: 'nun',
|
2019-04-25 10:28:40 +00:00
|
|
|
});
|
|
|
|
expect(res).toBeNull();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-04-25 10:28:40 +00:00
|
|
|
});
|
2019-02-19 14:58:42 +00:00
|
|
|
it('processes real data without project url (v3)', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://api-v2v3search-0.nuget.org')
|
|
|
|
.get('/query?q=nunit')
|
|
|
|
.reply(200, JSON.parse(pkgListV3WithoutProkjectUrl));
|
|
|
|
httpMock
|
|
|
|
.scope('https://myprivatefeed')
|
|
|
|
.get('/index.json')
|
|
|
|
.reply(200, JSON.parse(nugetIndexV3));
|
2020-06-18 19:31:40 +00:00
|
|
|
const res = await getPkgReleases({
|
2019-02-19 14:58:42 +00:00
|
|
|
...configV3NotNugetOrg,
|
|
|
|
});
|
|
|
|
expect(res).not.toBeNull();
|
|
|
|
expect(res).toMatchSnapshot();
|
|
|
|
expect(res.sourceUrl).not.toBeDefined();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-02-19 14:58:42 +00:00
|
|
|
});
|
2019-11-13 09:58:33 +00:00
|
|
|
it('processes real data with no github project url (v3)', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://api-v2v3search-0.nuget.org')
|
|
|
|
.get('/query?q=nunit')
|
|
|
|
.reply(200, JSON.parse(pkgListV3NoGitHubProjectUrl));
|
|
|
|
httpMock
|
|
|
|
.scope('https://myprivatefeed')
|
|
|
|
.get('/index.json')
|
|
|
|
.reply(200, JSON.parse(nugetIndexV3));
|
2020-06-18 19:31:40 +00:00
|
|
|
const res = await getPkgReleases({
|
2019-11-13 09:58:33 +00:00
|
|
|
...configV3NotNugetOrg,
|
|
|
|
});
|
|
|
|
expect(res).not.toBeNull();
|
|
|
|
expect(res).toMatchSnapshot();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-11-13 09:58:33 +00:00
|
|
|
});
|
2019-02-19 14:58:42 +00:00
|
|
|
it('processes real data (v2)', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://www.nuget.org')
|
|
|
|
.get(
|
|
|
|
'/api/v2//FindPackagesById()?id=%27nunit%27&$select=Version,IsLatestVersion,ProjectUrl'
|
|
|
|
)
|
|
|
|
.reply(200, pkgListV2);
|
2020-06-18 19:31:40 +00:00
|
|
|
const res = await getPkgReleases({
|
2019-02-19 14:58:42 +00:00
|
|
|
...configV2,
|
2019-02-04 08:41:22 +00:00
|
|
|
});
|
2018-06-14 13:52:37 +00:00
|
|
|
expect(res).not.toBeNull();
|
|
|
|
expect(res).toMatchSnapshot();
|
2018-12-10 04:59:28 +00:00
|
|
|
expect(res.sourceUrl).toBeDefined();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2018-06-14 09:15:52 +00:00
|
|
|
});
|
2019-09-17 10:55:22 +00:00
|
|
|
it('processes real data no relase (v2)', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://www.nuget.org')
|
|
|
|
.get(
|
|
|
|
'/api/v2//FindPackagesById()?id=%27nunit%27&$select=Version,IsLatestVersion,ProjectUrl'
|
|
|
|
)
|
|
|
|
.reply(200, pkgListV2NoRelease);
|
2020-06-18 19:31:40 +00:00
|
|
|
const res = await getPkgReleases({
|
2019-09-17 10:55:22 +00:00
|
|
|
...configV2,
|
|
|
|
});
|
|
|
|
expect(res).toBeNull();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-09-17 10:55:22 +00:00
|
|
|
});
|
2019-02-19 14:58:42 +00:00
|
|
|
it('processes real data without project url (v2)', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://www.nuget.org')
|
|
|
|
.get(
|
|
|
|
'/api/v2//FindPackagesById()?id=%27nunit%27&$select=Version,IsLatestVersion,ProjectUrl'
|
|
|
|
)
|
|
|
|
.reply(200, pkgListV2WithoutProjectUrl);
|
2020-06-18 19:31:40 +00:00
|
|
|
const res = await getPkgReleases({
|
2019-02-19 14:58:42 +00:00
|
|
|
...configV2,
|
|
|
|
});
|
|
|
|
expect(res).not.toBeNull();
|
|
|
|
expect(res).toMatchSnapshot();
|
|
|
|
expect(res.sourceUrl).not.toBeDefined();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-02-19 14:58:42 +00:00
|
|
|
});
|
2019-11-13 09:58:33 +00:00
|
|
|
it('processes real data with no github project url (v2)', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://www.nuget.org')
|
|
|
|
.get(
|
|
|
|
'/api/v2//FindPackagesById()?id=%27nunit%27&$select=Version,IsLatestVersion,ProjectUrl'
|
|
|
|
)
|
|
|
|
.reply(200, pkgListV2NoGitHubProjectUrl);
|
2020-06-18 19:31:40 +00:00
|
|
|
const res = await getPkgReleases({
|
2019-11-13 09:58:33 +00:00
|
|
|
...configV2,
|
|
|
|
});
|
|
|
|
expect(res).not.toBeNull();
|
|
|
|
expect(res).toMatchSnapshot();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-11-13 09:58:33 +00:00
|
|
|
});
|
2019-04-29 20:16:47 +00:00
|
|
|
it('handles paginated results (v2)', async () => {
|
2020-06-16 05:11:21 +00:00
|
|
|
httpMock
|
|
|
|
.scope('https://www.nuget.org')
|
|
|
|
.get(
|
|
|
|
'/api/v2//FindPackagesById()?id=%27nunit%27&$select=Version,IsLatestVersion,ProjectUrl'
|
|
|
|
)
|
|
|
|
.reply(200, pkgListV2Page1of2);
|
|
|
|
httpMock
|
|
|
|
.scope('https://example.org')
|
|
|
|
.get('/')
|
|
|
|
.reply(200, pkgListV2Page2of2);
|
2020-06-18 19:31:40 +00:00
|
|
|
const res = await getPkgReleases({
|
2019-04-29 20:16:47 +00:00
|
|
|
...configV2,
|
|
|
|
});
|
|
|
|
expect(res).not.toBeNull();
|
|
|
|
expect(res).toMatchSnapshot();
|
2020-06-16 05:11:21 +00:00
|
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
2019-04-29 20:16:47 +00:00
|
|
|
});
|
2018-06-14 09:15:52 +00:00
|
|
|
});
|
|
|
|
});
|