test: fix nock usage (#10451)
This commit is contained in:
Родитель
c7113f3821
Коммит
5546d60e18
|
@ -60,6 +60,9 @@ module.exports = {
|
|||
},
|
||||
],
|
||||
|
||||
// disallow direct `nock` module usage as it causes memory issues.
|
||||
'no-restricted-imports': [2, { paths: ['nock'] }],
|
||||
|
||||
// Makes no sense to allow type inference for expression parameters, but require typing the response
|
||||
'@typescript-eslint/explicit-function-return-type': [
|
||||
'error',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import nock from 'nock';
|
||||
import * as httpMock from '../../../../test/http-mock';
|
||||
import { getName } from '../../../../test/util';
|
||||
import { setAdminConfig } from '../../admin';
|
||||
import * as npm from '.';
|
||||
|
@ -10,13 +10,12 @@ describe(getName(), () => {
|
|||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
setAdminConfig();
|
||||
nock.cleanAll();
|
||||
});
|
||||
afterEach(() => {
|
||||
delete process.env.RENOVATE_CACHE_NPM_MINUTES;
|
||||
});
|
||||
it('should throw if no package', async () => {
|
||||
nock('https://registry.npmjs.org').get('/nopackage').reply(404);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/nopackage').reply(404);
|
||||
await expect(
|
||||
npm.getPreset({ packageName: 'nopackage', presetName: 'default' })
|
||||
).rejects.toThrow(/dep not found/);
|
||||
|
@ -45,7 +44,8 @@ describe(getName(), () => {
|
|||
'0.0.2': '2018-05-07T07:21:53+02:00',
|
||||
},
|
||||
};
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/norenovateconfig')
|
||||
.reply(200, presetPackage);
|
||||
await expect(
|
||||
|
@ -77,7 +77,8 @@ describe(getName(), () => {
|
|||
'0.0.2': '2018-05-07T07:21:53+02:00',
|
||||
},
|
||||
};
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/presetnamenotfound')
|
||||
.reply(200, presetPackage);
|
||||
await expect(
|
||||
|
@ -112,7 +113,8 @@ describe(getName(), () => {
|
|||
'0.0.2': '2018-05-07T07:21:53+02:00',
|
||||
},
|
||||
};
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/workingpreset')
|
||||
.reply(200, presetPackage);
|
||||
const res = await npm.getPreset({ packageName: 'workingpreset' });
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import nock from 'nock';
|
||||
import { getPkgReleases } from '..';
|
||||
import * as httpMock from '../../../test/http-mock';
|
||||
import { getName, loadFixture } from '../../../test/util';
|
||||
import * as mavenVersioning from '../../versioning/maven';
|
||||
import { MAVEN_REPO } from '../maven/common';
|
||||
import { parseIndexDir } from '../sbt-plugin/util';
|
||||
import * as sbtPlugin from '.';
|
||||
import * as sbtPackage from '.';
|
||||
|
||||
const mavenIndexHtml = loadFixture(`maven-index.html`);
|
||||
const sbtPluginIndex = loadFixture(`sbt-plugins-index.html`);
|
||||
|
@ -13,21 +13,27 @@ describe(getName(), () => {
|
|||
it('parses Maven index directory', () => {
|
||||
expect(parseIndexDir(mavenIndexHtml)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('parses sbt index directory', () => {
|
||||
expect(parseIndexDir(sbtPluginIndex)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
describe('getPkgReleases', () => {
|
||||
beforeEach(() => {
|
||||
nock.disableNetConnect();
|
||||
nock('https://failed_repo').get('/maven/org/scalatest/').reply(404, null);
|
||||
nock('https://repo.maven.apache.org')
|
||||
httpMock
|
||||
.scope('https://failed_repo')
|
||||
.get('/maven/org/scalatest/')
|
||||
.reply(404, null);
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get('/maven2/com/example/')
|
||||
.reply(200, '<a href="empty/">empty_2.12/</a>\n');
|
||||
nock('https://repo.maven.apache.org')
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get('/maven2/com/example/empty/')
|
||||
.reply(200, '');
|
||||
nock('https://repo.maven.apache.org')
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get('/maven2/org/scalatest/')
|
||||
.times(3)
|
||||
.reply(
|
||||
|
@ -40,22 +46,28 @@ describe(getName(), () => {
|
|||
'<a href="scalatest-flatspec_2.12/">scalatest-flatspec_2.12</a>' +
|
||||
'<a href="scalatest-matchers-core_2.12/">scalatest-matchers-core_2.12</a>'
|
||||
);
|
||||
nock('https://repo.maven.apache.org')
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get('/maven2/org/scalatest/scalatest/')
|
||||
.reply(200, "<a href='1.2.0/'>1.2.0/</a>");
|
||||
nock('https://repo.maven.apache.org')
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get('/maven2/org/scalatest/scalatest_2.12/')
|
||||
.reply(200, "<a href='1.2.3/'>4.5.6/</a>");
|
||||
nock('https://repo.maven.apache.org')
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get('/maven2/org/scalatest/scalatest-app_2.12/')
|
||||
.reply(200, "<a href='6.5.4/'>3.2.1/</a>");
|
||||
nock('https://repo.maven.apache.org')
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get('/maven2/org/scalatest/scalatest-flatspec_2.12/')
|
||||
.reply(200, "<a href='6.5.4/'>3.2.1/</a>");
|
||||
nock('https://repo.maven.apache.org')
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get('/maven2/org/scalatest/scalatest-matchers-core_2.12/')
|
||||
.reply(200, "<a href='6.5.4/'>3.2.1/</a>");
|
||||
nock('https://repo.maven.apache.org')
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get(
|
||||
'/maven2/org/scalatest/scalatest-app_2.12/6.5.4/scalatest-app_2.12-6.5.4.pom'
|
||||
)
|
||||
|
@ -68,7 +80,8 @@ describe(getName(), () => {
|
|||
'</scm>' +
|
||||
'</project>'
|
||||
);
|
||||
nock('https://repo.maven.apache.org')
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get(
|
||||
'/maven2/org/scalatest/scalatest-flatspec_2.12/6.5.4/scalatest-flatspec_2.12-6.5.4.pom'
|
||||
)
|
||||
|
@ -80,7 +93,8 @@ describe(getName(), () => {
|
|||
'</scm>' +
|
||||
'</project>'
|
||||
);
|
||||
nock('https://repo.maven.apache.org')
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get(
|
||||
'/maven2/org/scalatest/scalatest-matchers-core_2.12/6.5.4/scalatest-matchers-core_2.12-6.5.4.pom'
|
||||
)
|
||||
|
@ -91,10 +105,12 @@ describe(getName(), () => {
|
|||
'</project>'
|
||||
);
|
||||
|
||||
nock('https://dl.bintray.com')
|
||||
httpMock
|
||||
.scope('https://dl.bintray.com')
|
||||
.get('/sbt/sbt-plugin-releases/com.github.gseitz/')
|
||||
.reply(200, '');
|
||||
nock('https://dl.bintray.com')
|
||||
httpMock
|
||||
.scope('https://dl.bintray.com')
|
||||
.get('/sbt/sbt-plugin-releases/org.foundweekends/sbt-bintray/')
|
||||
.reply(
|
||||
200,
|
||||
|
@ -106,7 +122,8 @@ describe(getName(), () => {
|
|||
'</body>\n' +
|
||||
'</html>'
|
||||
);
|
||||
nock('https://dl.bintray.com')
|
||||
httpMock
|
||||
.scope('https://dl.bintray.com')
|
||||
.get(
|
||||
'/sbt/sbt-plugin-releases/org.foundweekends/sbt-bintray/scala_2.12/'
|
||||
)
|
||||
|
@ -121,7 +138,8 @@ describe(getName(), () => {
|
|||
'</body>\n' +
|
||||
'</html>\n'
|
||||
);
|
||||
nock('https://dl.bintray.com')
|
||||
httpMock
|
||||
.scope('https://dl.bintray.com')
|
||||
.get(
|
||||
'/sbt/sbt-plugin-releases/org.foundweekends/sbt-bintray/scala_2.12/sbt_1.0/'
|
||||
)
|
||||
|
@ -138,35 +156,36 @@ describe(getName(), () => {
|
|||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
nock.enableNetConnect();
|
||||
});
|
||||
// TODO: fix mocks
|
||||
afterEach(() => httpMock.clear(false));
|
||||
|
||||
it('returns null in case of errors', async () => {
|
||||
expect(
|
||||
await getPkgReleases({
|
||||
versioning: mavenVersioning.id,
|
||||
datasource: sbtPlugin.id,
|
||||
datasource: sbtPackage.id,
|
||||
depName: 'org.scalatest:scalatest',
|
||||
registryUrls: ['https://failed_repo/maven'],
|
||||
})
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null if there is no version', async () => {
|
||||
expect(
|
||||
await getPkgReleases({
|
||||
versioning: mavenVersioning.id,
|
||||
datasource: sbtPlugin.id,
|
||||
datasource: sbtPackage.id,
|
||||
depName: 'com.example:empty',
|
||||
registryUrls: [],
|
||||
})
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it('fetches releases from Maven', async () => {
|
||||
expect(
|
||||
await getPkgReleases({
|
||||
versioning: mavenVersioning.id,
|
||||
datasource: sbtPlugin.id,
|
||||
datasource: sbtPackage.id,
|
||||
depName: 'org.scalatest:scalatest',
|
||||
registryUrls: ['https://failed_repo/maven', MAVEN_REPO],
|
||||
})
|
||||
|
@ -175,10 +194,13 @@ describe(getName(), () => {
|
|||
registryUrl: 'https://repo.maven.apache.org/maven2',
|
||||
releases: [{ version: '1.2.0' }, { version: '1.2.3' }],
|
||||
});
|
||||
});
|
||||
|
||||
it('fetches releases from Maven 2', async () => {
|
||||
expect(
|
||||
await getPkgReleases({
|
||||
versioning: mavenVersioning.id,
|
||||
datasource: sbtPlugin.id,
|
||||
datasource: sbtPackage.id,
|
||||
depName: 'org.scalatest:scalatest_2.12',
|
||||
registryUrls: [],
|
||||
})
|
||||
|
@ -193,7 +215,7 @@ describe(getName(), () => {
|
|||
expect(
|
||||
await getPkgReleases({
|
||||
versioning: mavenVersioning.id,
|
||||
datasource: sbtPlugin.id,
|
||||
datasource: sbtPackage.id,
|
||||
depName: 'org.scalatest:scalatest-app_2.12',
|
||||
registryUrls: [],
|
||||
})
|
||||
|
@ -207,7 +229,7 @@ describe(getName(), () => {
|
|||
expect(
|
||||
await getPkgReleases({
|
||||
versioning: mavenVersioning.id,
|
||||
datasource: sbtPlugin.id,
|
||||
datasource: sbtPackage.id,
|
||||
depName: 'org.scalatest:scalatest-flatspec_2.12',
|
||||
registryUrls: [],
|
||||
})
|
||||
|
@ -220,7 +242,7 @@ describe(getName(), () => {
|
|||
expect(
|
||||
await getPkgReleases({
|
||||
versioning: mavenVersioning.id,
|
||||
datasource: sbtPlugin.id,
|
||||
datasource: sbtPackage.id,
|
||||
depName: 'org.scalatest:scalatest-matchers-core_2.12',
|
||||
registryUrls: [],
|
||||
})
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import nock from 'nock';
|
||||
import { getPkgReleases } from '..';
|
||||
import * as httpMock from '../../../test/http-mock';
|
||||
import { getName, loadFixture } from '../../../test/util';
|
||||
import * as mavenVersioning from '../../versioning/maven';
|
||||
import { MAVEN_REPO } from '../maven/common';
|
||||
|
@ -13,15 +13,19 @@ describe(getName(), () => {
|
|||
it('parses Maven index directory', () => {
|
||||
expect(parseIndexDir(mavenIndexHtml)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('parses sbt index directory', () => {
|
||||
expect(parseIndexDir(sbtPluginIndex)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
describe('getPkgReleases', () => {
|
||||
beforeEach(() => {
|
||||
nock.disableNetConnect();
|
||||
nock('https://failed_repo').get('/maven/org/scalatest/').reply(404, null);
|
||||
nock('https://repo.maven.apache.org')
|
||||
httpMock
|
||||
.scope('https://failed_repo')
|
||||
.get('/maven/org/scalatest/')
|
||||
.reply(404, null);
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get('/maven2/org/scalatest/')
|
||||
.reply(
|
||||
200,
|
||||
|
@ -30,17 +34,21 @@ describe(getName(), () => {
|
|||
"<a href='scalatest_sjs2.12/'>scalatest_2.12/</a>" +
|
||||
"<a href='scalatest_native2.12/'>scalatest_2.12/</a>"
|
||||
);
|
||||
nock('https://repo.maven.apache.org')
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get('/maven2/org/scalatest/scalatest/')
|
||||
.reply(200, "<a href='1.2.0/'>1.2.0/</a>");
|
||||
nock('https://repo.maven.apache.org')
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get('/maven2/org/scalatest/scalatest_2.12/')
|
||||
.reply(200, "<a href='1.2.3/'>4.5.6/</a>");
|
||||
|
||||
nock('https://dl.bintray.com')
|
||||
httpMock
|
||||
.scope('https://dl.bintray.com')
|
||||
.get('/sbt/sbt-plugin-releases/com.github.gseitz/')
|
||||
.reply(200, '');
|
||||
nock('https://dl.bintray.com')
|
||||
httpMock
|
||||
.scope('https://dl.bintray.com')
|
||||
.get('/sbt/sbt-plugin-releases/org.foundweekends/sbt-bintray/')
|
||||
.reply(
|
||||
200,
|
||||
|
@ -52,7 +60,8 @@ describe(getName(), () => {
|
|||
'</body>\n' +
|
||||
'</html>'
|
||||
);
|
||||
nock('https://dl.bintray.com')
|
||||
httpMock
|
||||
.scope('https://dl.bintray.com')
|
||||
.get(
|
||||
'/sbt/sbt-plugin-releases/org.foundweekends/sbt-bintray/scala_2.12/'
|
||||
)
|
||||
|
@ -67,7 +76,8 @@ describe(getName(), () => {
|
|||
'</body>\n' +
|
||||
'</html>\n'
|
||||
);
|
||||
nock('https://dl.bintray.com')
|
||||
httpMock
|
||||
.scope('https://dl.bintray.com')
|
||||
.get(
|
||||
'/sbt/sbt-plugin-releases/org.foundweekends/sbt-bintray/scala_2.12/sbt_1.0/'
|
||||
)
|
||||
|
@ -83,7 +93,8 @@ describe(getName(), () => {
|
|||
'</html>\n'
|
||||
);
|
||||
|
||||
nock('https://repo.maven.apache.org')
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get('/maven2/io/get-coursier/')
|
||||
.reply(
|
||||
200,
|
||||
|
@ -92,7 +103,8 @@ describe(getName(), () => {
|
|||
'<a href="sbt-coursier_2.12_1.0.0-M5/">sbt-coursier_2.12_1.0.0-M5/</a>\n' +
|
||||
'<a href="sbt-coursier_2.12_1.0.0-M6/">sbt-coursier_2.12_1.0.0-M6/</a>\n'
|
||||
);
|
||||
nock('https://repo.maven.apache.org')
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get('/maven2/io/get-coursier/sbt-coursier_2.12_1.0/')
|
||||
.reply(
|
||||
200,
|
||||
|
@ -101,7 +113,8 @@ describe(getName(), () => {
|
|||
'<a href="2.0.0-RC6-2/">2.0.0-RC6-2/</a>\n' +
|
||||
'<a href="2.0.0-RC6-6/">2.0.0-RC6-6/</a>\n'
|
||||
);
|
||||
nock('https://repo.maven.apache.org')
|
||||
httpMock
|
||||
.scope('https://repo.maven.apache.org')
|
||||
.get(
|
||||
'/maven2/io/get-coursier/sbt-coursier_2.12_1.0/2.0.0-RC6-6/sbt-coursier-2.0.0-RC6-6.pom'
|
||||
)
|
||||
|
@ -116,9 +129,8 @@ describe(getName(), () => {
|
|||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
nock.enableNetConnect();
|
||||
});
|
||||
// TODO: fix mocks
|
||||
afterEach(() => httpMock.clear(false));
|
||||
|
||||
it('returns null in case of errors', async () => {
|
||||
expect(
|
||||
|
@ -138,6 +150,7 @@ describe(getName(), () => {
|
|||
})
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it('fetches sbt plugins', async () => {
|
||||
expect(
|
||||
await getPkgReleases({
|
||||
|
@ -152,6 +165,8 @@ describe(getName(), () => {
|
|||
registryUrl: 'https://dl.bintray.com/sbt/sbt-plugin-releases',
|
||||
releases: [{ version: '0.5.5' }],
|
||||
});
|
||||
});
|
||||
it('fetches sbt plugins 2', async () => {
|
||||
expect(
|
||||
await getPkgReleases({
|
||||
versioning: mavenVersioning.id,
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import nock from 'nock';
|
||||
import * as httpMock from '../../../test/http-mock';
|
||||
import { getName } from '../../../test/util';
|
||||
import {
|
||||
|
@ -181,7 +180,7 @@ describe(getName(), () => {
|
|||
const username = 'abc';
|
||||
const password = '123';
|
||||
|
||||
async function initRepo(config = {}): Promise<nock.Scope> {
|
||||
async function initRepo(config = {}): Promise<httpMock.Scope> {
|
||||
const scope = httpMock
|
||||
.scope(urlHost)
|
||||
.get(`${urlPath}/rest/api/1.0/projects/SOME/repos/repo`)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import nock from 'nock';
|
||||
import * as httpMock from '../../../test/http-mock';
|
||||
import { getName } from '../../../test/util';
|
||||
import { logger as _logger } from '../../logger';
|
||||
|
@ -65,8 +64,8 @@ describe(getName(), () => {
|
|||
async function initRepoMock(
|
||||
config?: Partial<RepoParams>,
|
||||
repoResp?: any,
|
||||
existingScope?: nock.Scope
|
||||
): Promise<nock.Scope> {
|
||||
existingScope?: httpMock.Scope
|
||||
): Promise<httpMock.Scope> {
|
||||
const repository = config?.repository || 'some/repo';
|
||||
|
||||
const scope = existingScope || httpMock.scope(baseUrl);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// TODO fix mocks
|
||||
import nock from 'nock';
|
||||
import { Platform, RepoParams } from '..';
|
||||
import * as httpMock from '../../../test/http-mock';
|
||||
import { getName } from '../../../test/util';
|
||||
|
@ -163,7 +162,7 @@ describe(getName(), () => {
|
|||
},
|
||||
repoResp = null,
|
||||
scope = httpMock.scope(gitlabApiHost)
|
||||
): Promise<nock.Scope> {
|
||||
): Promise<httpMock.Scope> {
|
||||
const repo = repoParams.repository;
|
||||
const justRepo = repo.split('/').slice(0, 2).join('/');
|
||||
scope.get(`/api/v4/projects/${encodeURIComponent(repo)}`).reply(
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import nock from 'nock';
|
||||
import * as httpMock from '../../../test/http-mock';
|
||||
import { getName } from '../../../test/util';
|
||||
import {
|
||||
|
@ -105,7 +104,7 @@ describe(getName(), () => {
|
|||
async function fail(
|
||||
code: number,
|
||||
body: any = undefined,
|
||||
headers: nock.ReplyHeaders = undefined
|
||||
headers: httpMock.ReplyHeaders = undefined
|
||||
) {
|
||||
const url = '/some-url';
|
||||
httpMock
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import nock from 'nock';
|
||||
import * as httpMock from '../../../test/http-mock';
|
||||
import { getName } from '../../../test/util';
|
||||
import {
|
||||
EXTERNAL_HOST_ERROR,
|
||||
|
@ -15,29 +15,28 @@ describe(getName(), () => {
|
|||
|
||||
beforeEach(() => {
|
||||
http = new Http('dummy');
|
||||
nock.cleanAll();
|
||||
hostRules.clear();
|
||||
queue.clear();
|
||||
});
|
||||
it('get', async () => {
|
||||
nock(baseUrl).get('/test').reply(200);
|
||||
httpMock.scope(baseUrl).get('/test').reply(200);
|
||||
expect(await http.get('http://renovate.com/test')).toMatchSnapshot();
|
||||
expect(nock.isDone()).toBe(true);
|
||||
expect(httpMock.allUsed()).toBe(true);
|
||||
});
|
||||
it('returns 429 error', async () => {
|
||||
nock(baseUrl).get('/test').reply(429);
|
||||
httpMock.scope(baseUrl).get('/test').reply(429);
|
||||
await expect(http.get('http://renovate.com/test')).rejects.toThrow(
|
||||
'Response code 429 (Too Many Requests)'
|
||||
);
|
||||
expect(nock.isDone()).toBe(true);
|
||||
expect(httpMock.allUsed()).toBe(true);
|
||||
});
|
||||
it('converts 404 error to ExternalHostError', async () => {
|
||||
nock(baseUrl).get('/test').reply(404);
|
||||
httpMock.scope(baseUrl).get('/test').reply(404);
|
||||
hostRules.add({ abortOnError: true });
|
||||
await expect(http.get('http://renovate.com/test')).rejects.toThrow(
|
||||
EXTERNAL_HOST_ERROR
|
||||
);
|
||||
expect(nock.isDone()).toBe(true);
|
||||
expect(httpMock.allUsed()).toBe(true);
|
||||
});
|
||||
it('disables hosts', async () => {
|
||||
hostRules.add({ matchHost: 'renovate.com', enabled: false });
|
||||
|
@ -46,55 +45,55 @@ describe(getName(), () => {
|
|||
);
|
||||
});
|
||||
it('ignores 404 error and does not throw ExternalHostError', async () => {
|
||||
nock(baseUrl).get('/test').reply(404);
|
||||
httpMock.scope(baseUrl).get('/test').reply(404);
|
||||
hostRules.add({ abortOnError: true, abortIgnoreStatusCodes: [404] });
|
||||
await expect(http.get('http://renovate.com/test')).rejects.toThrow(
|
||||
'Response code 404 (Not Found)'
|
||||
);
|
||||
expect(nock.isDone()).toBe(true);
|
||||
expect(httpMock.allUsed()).toBe(true);
|
||||
});
|
||||
it('getJson', async () => {
|
||||
nock(baseUrl).get('/').reply(200, '{ "test": true }');
|
||||
httpMock.scope(baseUrl).get('/').reply(200, '{ "test": true }');
|
||||
expect(await http.getJson('http://renovate.com')).toMatchSnapshot();
|
||||
});
|
||||
it('postJson', async () => {
|
||||
nock(baseUrl).post('/').reply(200, {});
|
||||
httpMock.scope(baseUrl).post('/').reply(200, {});
|
||||
expect(
|
||||
await http.postJson('http://renovate.com', { body: {}, baseUrl })
|
||||
).toMatchSnapshot();
|
||||
expect(nock.isDone()).toBe(true);
|
||||
expect(httpMock.allUsed()).toBe(true);
|
||||
});
|
||||
it('putJson', async () => {
|
||||
nock(baseUrl).put('/').reply(200, {});
|
||||
httpMock.scope(baseUrl).put('/').reply(200, {});
|
||||
expect(
|
||||
await http.putJson('http://renovate.com', { body: {}, baseUrl })
|
||||
).toMatchSnapshot();
|
||||
expect(nock.isDone()).toBe(true);
|
||||
expect(httpMock.allUsed()).toBe(true);
|
||||
});
|
||||
it('patchJson', async () => {
|
||||
nock(baseUrl).patch('/').reply(200, {});
|
||||
httpMock.scope(baseUrl).patch('/').reply(200, {});
|
||||
expect(
|
||||
await http.patchJson('http://renovate.com', { body: {}, baseUrl })
|
||||
).toMatchSnapshot();
|
||||
expect(nock.isDone()).toBe(true);
|
||||
expect(httpMock.allUsed()).toBe(true);
|
||||
});
|
||||
it('deleteJson', async () => {
|
||||
nock(baseUrl).delete('/').reply(200, {});
|
||||
httpMock.scope(baseUrl).delete('/').reply(200, {});
|
||||
expect(
|
||||
await http.deleteJson('http://renovate.com', { body: {}, baseUrl })
|
||||
).toMatchSnapshot();
|
||||
expect(nock.isDone()).toBe(true);
|
||||
expect(httpMock.allUsed()).toBe(true);
|
||||
});
|
||||
it('headJson', async () => {
|
||||
nock(baseUrl).head('/').reply(200, {});
|
||||
httpMock.scope(baseUrl).head('/').reply(200, {});
|
||||
expect(
|
||||
await http.headJson('http://renovate.com', { baseUrl })
|
||||
).toMatchSnapshot();
|
||||
expect(nock.isDone()).toBe(true);
|
||||
expect(httpMock.allUsed()).toBe(true);
|
||||
});
|
||||
|
||||
it('stream', async () => {
|
||||
nock(baseUrl).get('/some').reply(200, {});
|
||||
httpMock.scope(baseUrl).get('/some').reply(200, {});
|
||||
|
||||
const stream = http.stream('/some', {
|
||||
baseUrl,
|
||||
|
@ -115,20 +114,21 @@ describe(getName(), () => {
|
|||
await done;
|
||||
|
||||
expect(data).toBe('{}');
|
||||
expect(nock.isDone()).toBe(true);
|
||||
expect(httpMock.allUsed()).toBe(true);
|
||||
});
|
||||
|
||||
it('retries', async () => {
|
||||
const NODE_ENV = process.env.NODE_ENV;
|
||||
try {
|
||||
delete process.env.NODE_ENV;
|
||||
nock(baseUrl)
|
||||
httpMock
|
||||
.scope(baseUrl)
|
||||
.head('/')
|
||||
.reply(500)
|
||||
.head('/')
|
||||
.reply(200, undefined, { 'x-some-header': 'abc' });
|
||||
expect(await http.head('http://renovate.com')).toMatchSnapshot();
|
||||
expect(nock.isDone()).toBe(true);
|
||||
expect(httpMock.allUsed()).toBe(true);
|
||||
} finally {
|
||||
process.env.NODE_ENV = NODE_ENV;
|
||||
}
|
||||
|
@ -158,7 +158,8 @@ describe(getName(), () => {
|
|||
const [fooReq, fooStart, fooResp, fooFinish] = mockRequestResponse();
|
||||
const [barReq, barStart, barResp, barFinish] = mockRequestResponse();
|
||||
|
||||
nock(baseUrl)
|
||||
httpMock
|
||||
.scope(baseUrl)
|
||||
.get('/foo')
|
||||
.reply(200, () => {
|
||||
foo = true;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import nock from 'nock';
|
||||
import * as httpMock from '../../../../../test/http-mock';
|
||||
import {
|
||||
getConfig,
|
||||
getName,
|
||||
|
@ -59,6 +59,9 @@ describe(getName(), () => {
|
|||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
// TODO: fix mocks
|
||||
afterEach(() => httpMock.clear(false));
|
||||
|
||||
describe('.lookupUpdates()', () => {
|
||||
it('returns null if unknown datasource', async () => {
|
||||
config.depName = 'some-dep';
|
||||
|
@ -70,7 +73,7 @@ describe(getName(), () => {
|
|||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
config.rollbackPrs = true;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('returns rollback for ranged version', async () => {
|
||||
|
@ -78,7 +81,7 @@ describe(getName(), () => {
|
|||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
config.rollbackPrs = true;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('supports minor and major upgrades for tilde ranges', async () => {
|
||||
|
@ -86,7 +89,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'pin';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('supports lock file updates mixed with regular updates', async () => {
|
||||
|
@ -96,7 +99,7 @@ describe(getName(), () => {
|
|||
config.datasource = datasourceNpmId;
|
||||
config.separateMinorPatch = true;
|
||||
config.lockedVersion = '0.4.0';
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('returns multiple updates if grouping but separateMajorMinor=true', async () => {
|
||||
|
@ -105,7 +108,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'pin';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res.updates).toMatchSnapshot();
|
||||
expect(res.updates).toHaveLength(2);
|
||||
|
@ -117,7 +120,7 @@ describe(getName(), () => {
|
|||
config.depName = 'q';
|
||||
config.separateMinorPatch = true;
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res.updates).toMatchSnapshot();
|
||||
expect(res.updates).toHaveLength(3);
|
||||
|
@ -129,7 +132,7 @@ describe(getName(), () => {
|
|||
config.separateMajorMinor = false;
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res.updates).toMatchSnapshot();
|
||||
expect(res.updates).toHaveLength(1);
|
||||
|
@ -140,7 +143,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'pin';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('enforces allowedVersions', async () => {
|
||||
|
@ -148,7 +151,7 @@ describe(getName(), () => {
|
|||
config.allowedVersions = '<1';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toHaveLength(1);
|
||||
});
|
||||
it('enforces allowedVersions with regex', async () => {
|
||||
|
@ -156,7 +159,7 @@ describe(getName(), () => {
|
|||
config.allowedVersions = '/^0/';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toHaveLength(1);
|
||||
});
|
||||
it('enforces allowedVersions with negative regex', async () => {
|
||||
|
@ -164,7 +167,7 @@ describe(getName(), () => {
|
|||
config.allowedVersions = '!/^1/';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toHaveLength(1);
|
||||
});
|
||||
it('falls back to semver syntax allowedVersions', async () => {
|
||||
|
@ -173,7 +176,7 @@ describe(getName(), () => {
|
|||
config.depName = 'q';
|
||||
config.versioning = dockerVersioningId; // this doesn't make sense but works for this test
|
||||
config.datasource = datasourceNpmId; // this doesn't make sense but works for this test
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toHaveLength(1);
|
||||
});
|
||||
it('falls back to pep440 syntax allowedVersions', async () => {
|
||||
|
@ -182,7 +185,7 @@ describe(getName(), () => {
|
|||
config.depName = 'q';
|
||||
config.versioning = poetryVersioningId; // this doesn't make sense but works for this test
|
||||
config.datasource = datasourceNpmId; // this doesn't make sense but works for this test
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toHaveLength(1);
|
||||
});
|
||||
it('skips invalid allowedVersions', async () => {
|
||||
|
@ -190,7 +193,7 @@ describe(getName(), () => {
|
|||
config.allowedVersions = 'less than 1';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
await expect(lookup.lookupUpdates(config)).rejects.toThrow(
|
||||
Error(CONFIG_VALIDATION)
|
||||
);
|
||||
|
@ -200,7 +203,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'pin';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res.updates).toMatchSnapshot();
|
||||
expect(res.updates).toHaveLength(2);
|
||||
|
@ -218,7 +221,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'pin';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res.updates).toMatchSnapshot();
|
||||
expect(res.updates[0].updateType).toEqual('patch');
|
||||
|
@ -229,7 +232,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'pin';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('returns patch minor and major', async () => {
|
||||
|
@ -238,7 +241,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'pin';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res.updates).toHaveLength(3);
|
||||
expect(res.updates).toMatchSnapshot();
|
||||
|
@ -249,7 +252,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'pin';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('disables major release separation (minor)', async () => {
|
||||
|
@ -258,7 +261,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'pin';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('uses minimum version for vulnerabilityAlerts', async () => {
|
||||
|
@ -266,7 +269,7 @@ describe(getName(), () => {
|
|||
config.isVulnerabilityAlert = true;
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = (await lookup.lookupUpdates(config)).updates;
|
||||
expect(res).toMatchSnapshot();
|
||||
expect(res).toHaveLength(1);
|
||||
|
@ -276,7 +279,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'pin';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('ignores pinning for ranges when other upgrade exists', async () => {
|
||||
|
@ -284,7 +287,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'pin';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('upgrades minor ranged versions', async () => {
|
||||
|
@ -292,7 +295,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'pin';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('handles update-lockfile', async () => {
|
||||
|
@ -301,7 +304,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'update-lockfile';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res.updates).toMatchSnapshot();
|
||||
expect(res.updates[0].updateType).toEqual('minor');
|
||||
|
@ -311,7 +314,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'widen';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('replaces minor complex ranged versions if configured', async () => {
|
||||
|
@ -319,7 +322,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'replace';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('widens major ranged versions if configured', async () => {
|
||||
|
@ -327,7 +330,8 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'widen';
|
||||
config.depName = 'webpack';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/webpack')
|
||||
.reply(200, webpackJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
|
@ -337,7 +341,8 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'replace';
|
||||
config.depName = 'webpack';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/webpack')
|
||||
.reply(200, webpackJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
|
@ -347,7 +352,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'pin';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('uses the locked version for pinning', async () => {
|
||||
|
@ -356,7 +361,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'pin';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('ignores minor ranged versions when not pinning', async () => {
|
||||
|
@ -364,7 +369,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '^1.0.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toHaveLength(0);
|
||||
});
|
||||
it('ignores minor ranged versions when locked', async () => {
|
||||
|
@ -373,7 +378,7 @@ describe(getName(), () => {
|
|||
config.lockedVersion = '1.1.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toHaveLength(0);
|
||||
});
|
||||
it('upgrades tilde ranges', async () => {
|
||||
|
@ -381,7 +386,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '~1.3.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('upgrades .x minor ranges', async () => {
|
||||
|
@ -389,7 +394,7 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'pin';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('upgrades tilde ranges without pinning', async () => {
|
||||
|
@ -397,7 +402,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '~1.3.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('upgrades .x major ranges without pinning', async () => {
|
||||
|
@ -405,7 +410,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '0.x';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('upgrades .x minor ranges without pinning', async () => {
|
||||
|
@ -413,7 +418,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '1.3.x';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('upgrades .x complex minor ranges without pinning', async () => {
|
||||
|
@ -421,7 +426,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '1.2.x - 1.3.x';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('upgrades shorthand major ranges without pinning', async () => {
|
||||
|
@ -429,7 +434,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('upgrades shorthand minor ranges without pinning', async () => {
|
||||
|
@ -437,7 +442,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '1.3';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('upgrades multiple tilde ranges without pinning', async () => {
|
||||
|
@ -445,7 +450,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '~0.7.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('upgrades multiple caret ranges without pinning', async () => {
|
||||
|
@ -453,7 +458,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '^0.7.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('supports complex ranges', async () => {
|
||||
|
@ -461,7 +466,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '^0.7.0 || ^0.8.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res.updates).toHaveLength(2);
|
||||
expect(res.updates[0]).toMatchSnapshot();
|
||||
|
@ -471,7 +476,8 @@ describe(getName(), () => {
|
|||
config.currentValue = '^1.0.0 || ^2.0.0';
|
||||
config.depName = 'webpack';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/webpack')
|
||||
.reply(200, webpackJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
|
@ -481,7 +487,8 @@ describe(getName(), () => {
|
|||
config.currentValue = '1.x - 2.x';
|
||||
config.depName = 'webpack';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/webpack')
|
||||
.reply(200, webpackJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
|
@ -491,7 +498,8 @@ describe(getName(), () => {
|
|||
config.currentValue = '1.x || 2.x';
|
||||
config.depName = 'webpack';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/webpack')
|
||||
.reply(200, webpackJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
|
@ -501,7 +509,8 @@ describe(getName(), () => {
|
|||
config.currentValue = '1 || 2';
|
||||
config.depName = 'webpack';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/webpack')
|
||||
.reply(200, webpackJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
|
@ -511,7 +520,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '~1.2.0 || ~1.3.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('returns nothing for greater than ranges', async () => {
|
||||
|
@ -519,7 +528,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '>= 0.7.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toHaveLength(0);
|
||||
});
|
||||
it('upgrades less than equal ranges without pinning', async () => {
|
||||
|
@ -527,7 +536,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '<= 0.7.2';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('upgrades less than ranges without pinning', async () => {
|
||||
|
@ -535,7 +544,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '< 0.7.2';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('upgrades less than major ranges', async () => {
|
||||
|
@ -543,7 +552,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '< 1';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('upgrades less than equal minor ranges', async () => {
|
||||
|
@ -551,7 +560,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '<= 1.3';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('upgrades equal minor ranges', async () => {
|
||||
|
@ -559,7 +568,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '=1.3.1';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('upgrades less than equal major ranges', async () => {
|
||||
|
@ -568,7 +577,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '<= 1';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('upgrades major less than equal ranges', async () => {
|
||||
|
@ -576,7 +585,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '<= 1.0.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res.updates).toMatchSnapshot();
|
||||
expect(res.updates[0].newValue).toEqual('<= 1.4.1');
|
||||
|
@ -586,7 +595,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '< 1.0.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res.updates).toMatchSnapshot();
|
||||
expect(res.updates[0].newValue).toEqual('< 2.0.0');
|
||||
|
@ -596,7 +605,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '>= 0.5.0 < 1.0.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res.updates).toMatchSnapshot();
|
||||
expect(res.updates[0].newValue).toEqual('>= 0.5.0 < 2.0.0');
|
||||
|
@ -606,7 +615,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '>= 0.5.0 <0.8';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res.updates).toMatchSnapshot();
|
||||
expect(res.updates[0].newValue).toEqual('>= 0.5.0 <0.10');
|
||||
|
@ -617,7 +626,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '>= 0.5.0 <= 0.8.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res.updates).toMatchSnapshot();
|
||||
expect(res.updates[0].newValue).toEqual('>= 0.5.0 <= 0.9.7');
|
||||
|
@ -628,7 +637,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '<= 0.8.0 >= 0.5.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res.updates).toMatchSnapshot();
|
||||
});
|
||||
|
@ -637,14 +646,17 @@ describe(getName(), () => {
|
|||
config.currentValue = '1.4.1';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('should ignore unstable versions if the current version is stable', async () => {
|
||||
config.currentValue = '2.5.16';
|
||||
config.depName = 'vue';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/vue').reply(200, vueJson);
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/vue')
|
||||
.reply(200, vueJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toHaveLength(0);
|
||||
});
|
||||
it('should ignore unstable versions from datasource', async () => {
|
||||
|
@ -736,7 +748,10 @@ describe(getName(), () => {
|
|||
config.respectLatest = false;
|
||||
config.depName = 'vue';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/vue').reply(200, vueJson);
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/vue')
|
||||
.reply(200, vueJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res.updates).toMatchSnapshot();
|
||||
expect(res.updates).toHaveLength(1);
|
||||
|
@ -746,7 +761,8 @@ describe(getName(), () => {
|
|||
config.currentValue = '3.1.0-dev.20180731';
|
||||
config.depName = 'typescript';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/typescript')
|
||||
.reply(200, typescriptJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
|
@ -758,7 +774,8 @@ describe(getName(), () => {
|
|||
config.currentValue = '3.0.1-insiders.20180726';
|
||||
config.depName = 'typescript';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/typescript')
|
||||
.reply(200, typescriptJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
|
@ -771,7 +788,8 @@ describe(getName(), () => {
|
|||
config.depName = 'typescript';
|
||||
config.datasource = datasourceNpmId;
|
||||
config.followTag = 'insiders';
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/typescript')
|
||||
.reply(200, typescriptJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
|
@ -785,7 +803,8 @@ describe(getName(), () => {
|
|||
config.datasource = datasourceNpmId;
|
||||
config.followTag = 'insiders';
|
||||
config.rollbackPrs = true;
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/typescript')
|
||||
.reply(200, typescriptJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
|
@ -798,7 +817,8 @@ describe(getName(), () => {
|
|||
config.depName = 'typescript';
|
||||
config.datasource = datasourceNpmId;
|
||||
config.followTag = 'insiders';
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/typescript')
|
||||
.reply(200, typescriptJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
|
@ -811,7 +831,8 @@ describe(getName(), () => {
|
|||
config.depName = 'typescript';
|
||||
config.datasource = datasourceNpmId;
|
||||
config.followTag = 'insiders';
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/typescript')
|
||||
.reply(200, typescriptJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
|
@ -822,7 +843,8 @@ describe(getName(), () => {
|
|||
config.depName = 'typescript';
|
||||
config.datasource = datasourceNpmId;
|
||||
config.followTag = 'foo';
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/typescript')
|
||||
.reply(200, typescriptJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
|
@ -838,7 +860,8 @@ describe(getName(), () => {
|
|||
config.currentValue = '~0.0.34';
|
||||
config.depName = '@types/helmet';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/@types%2Fhelmet')
|
||||
.reply(200, helmetJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toEqual([]);
|
||||
|
@ -848,7 +871,8 @@ describe(getName(), () => {
|
|||
config.currentValue = '^0.0.34';
|
||||
config.depName = '@types/helmet';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/@types%2Fhelmet')
|
||||
.reply(200, helmetJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
|
@ -858,7 +882,8 @@ describe(getName(), () => {
|
|||
config.depName = 'coffeelint';
|
||||
config.datasource = datasourceNpmId;
|
||||
config.rollbackPrs = true;
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/coffeelint')
|
||||
.reply(200, coffeelintJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
|
@ -869,7 +894,8 @@ describe(getName(), () => {
|
|||
config.currentValue = '1.0.0';
|
||||
config.depName = 'webpack';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/webpack')
|
||||
.reply(200, webpackJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
|
@ -880,7 +906,8 @@ describe(getName(), () => {
|
|||
config.separateMultipleMajor = true;
|
||||
config.depName = 'webpack';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org')
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/webpack')
|
||||
.reply(200, webpackJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
|
@ -891,7 +918,10 @@ describe(getName(), () => {
|
|||
config.rangeStrategy = 'replace';
|
||||
config.depName = 'next';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/next').reply(200, nextJson);
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/next')
|
||||
.reply(200, nextJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res.updates).toHaveLength(0);
|
||||
});
|
||||
|
@ -900,7 +930,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '^1.0.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('supports in-range tilde updates', async () => {
|
||||
|
@ -909,7 +939,7 @@ describe(getName(), () => {
|
|||
config.depName = 'q';
|
||||
config.separateMinorPatch = true;
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('supports in-range tilde patch updates', async () => {
|
||||
|
@ -918,7 +948,7 @@ describe(getName(), () => {
|
|||
config.depName = 'q';
|
||||
config.separateMinorPatch = true;
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('supports in-range gte updates', async () => {
|
||||
|
@ -926,7 +956,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '>=1.0.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('supports majorgte updates', async () => {
|
||||
|
@ -935,7 +965,7 @@ describe(getName(), () => {
|
|||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
config.separateMajorMinor = false;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('rejects in-range unsupported operator', async () => {
|
||||
|
@ -943,7 +973,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '>1.0.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('rejects non-fully specified in-range updates', async () => {
|
||||
|
@ -951,7 +981,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '1.x';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('rejects complex range in-range updates', async () => {
|
||||
|
@ -959,7 +989,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '^0.9.0 || ^1.0.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('replaces non-range in-range updates', async () => {
|
||||
|
@ -968,7 +998,7 @@ describe(getName(), () => {
|
|||
config.packageFile = 'package.json';
|
||||
config.rangeStrategy = 'bump';
|
||||
config.currentValue = '1.0.0';
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('handles github 404', async () => {
|
||||
|
@ -976,7 +1006,7 @@ describe(getName(), () => {
|
|||
config.datasource = datasourceGithubTagsId;
|
||||
config.packageFile = 'package.json';
|
||||
config.currentValue = '1.0.0';
|
||||
nock('https://pypi.org').get('/pypi/foo/json').reply(404);
|
||||
httpMock.scope('https://pypi.org').get('/pypi/foo/json').reply(404);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('handles pypi 404', async () => {
|
||||
|
@ -984,7 +1014,8 @@ describe(getName(), () => {
|
|||
config.datasource = datasourcePypiId;
|
||||
config.packageFile = 'requirements.txt';
|
||||
config.currentValue = '1.0.0';
|
||||
nock('https://api.github.com')
|
||||
httpMock
|
||||
.scope('https://api.github.com')
|
||||
.get('/repos/some/repo/git/refs/tags?per_page=100')
|
||||
.reply(404);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
|
@ -995,7 +1026,10 @@ describe(getName(), () => {
|
|||
config.packageFile = 'composer.json';
|
||||
config.currentValue = '1.0.0';
|
||||
config.registryUrls = ['https://packagist.org'];
|
||||
nock('https://packagist.org').get('/packages/foo/bar.json').reply(404);
|
||||
httpMock
|
||||
.scope('https://packagist.org')
|
||||
.get('/packages/foo/bar.json')
|
||||
.reply(404);
|
||||
expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot();
|
||||
});
|
||||
it('handles unknown datasource', async () => {
|
||||
|
@ -1016,7 +1050,7 @@ describe(getName(), () => {
|
|||
config.depName = 'q';
|
||||
// TODO: we are using npm as source to test pep440 (#9721)
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res.updates).toMatchSnapshot();
|
||||
});
|
||||
|
@ -1024,7 +1058,7 @@ describe(getName(), () => {
|
|||
config.currentValue = '1.3.0';
|
||||
config.depName = 'q';
|
||||
config.datasource = datasourceNpmId;
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res).toMatchSnapshot();
|
||||
expect(res.sourceUrl).toBeDefined();
|
||||
|
@ -1036,7 +1070,10 @@ describe(getName(), () => {
|
|||
const returnJson = JSON.parse(JSON.stringify(qJson));
|
||||
returnJson.name = 'q2';
|
||||
returnJson.versions['1.4.1'].deprecated = 'true';
|
||||
nock('https://registry.npmjs.org').get('/q2').reply(200, returnJson);
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/q2')
|
||||
.reply(200, returnJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res).toMatchSnapshot();
|
||||
expect(res.updates[0].newVersion).toEqual('1.4.0');
|
||||
|
@ -1052,7 +1089,10 @@ describe(getName(), () => {
|
|||
repository: { url: null, directory: 'test' },
|
||||
};
|
||||
|
||||
nock('https://registry.npmjs.org').get('/q3').reply(200, returnJson);
|
||||
httpMock
|
||||
.scope('https://registry.npmjs.org')
|
||||
.get('/q3')
|
||||
.reply(200, returnJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res).toMatchSnapshot();
|
||||
expect(res.updates[0].newVersion).toEqual('1.4.1');
|
||||
|
@ -1248,7 +1288,7 @@ describe(getName(), () => {
|
|||
allowedVersions: '< 1.4.0',
|
||||
},
|
||||
];
|
||||
nock('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
httpMock.scope('https://registry.npmjs.org').get('/q').reply(200, qJson);
|
||||
const res = await lookup.lookupUpdates(config);
|
||||
expect(res).toMatchSnapshot();
|
||||
});
|
||||
|
|
|
@ -2,9 +2,11 @@ import { Url } from 'url';
|
|||
import { afterAll, afterEach, beforeAll } from '@jest/globals';
|
||||
import is from '@sindresorhus/is';
|
||||
import { parse as parseGraphqlQuery } from 'graphql/language';
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import nock from 'nock';
|
||||
|
||||
export type { Scope } from 'nock';
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
export type { Scope, ReplyHeaders } from 'nock';
|
||||
|
||||
interface RequestLogItem {
|
||||
headers: Record<string, string>;
|
||||
|
|
Загрузка…
Ссылка в новой задаче