diff --git a/lib/datasource/clojure/index.spec.ts b/lib/datasource/clojure/index.spec.ts index 546bb2e44192b33c509f8b51d350d71c2f908828..8fa371a74e6c05680532edc4b57979b45502296a 100644 --- a/lib/datasource/clojure/index.spec.ts +++ b/lib/datasource/clojure/index.spec.ts @@ -233,6 +233,11 @@ describe(getName(), () => { const pom = loadFixture('pom.scm-prefix.xml', upath.join('..', 'maven')); mockGenericPackage({ pom }); + httpMock + .scope('https://repo.maven.apache.org') + .get('/maven2/org/example/package/maven-metadata.xml') + .reply(200, '###'); + const { sourceUrl } = await get(); expect(sourceUrl).toEqual('https://github.com/example/test'); diff --git a/lib/datasource/crate/index.spec.ts b/lib/datasource/crate/index.spec.ts index b62822b12eb36b98ddc499857d273ee3740eb674..47ba3457020627235aef5f357695ee9f839507ad 100644 --- a/lib/datasource/crate/index.spec.ts +++ b/lib/datasource/crate/index.spec.ts @@ -97,6 +97,8 @@ describe(getName(), () => { }); it('returns null for missing registry url', async () => { + // FIXME: should not call default registry? + httpMock.scope(baseUrl).get('/no/n_/non_existent_crate').reply(404, {}); expect( await getPkgReleases({ datasource, diff --git a/lib/datasource/helm/index.spec.ts b/lib/datasource/helm/index.spec.ts index 83ce27950c93945a1023d4c67f1ff4c33a5708b3..1cb2105ceca9570a0efabc47790dbb7208871b2d 100644 --- a/lib/datasource/helm/index.spec.ts +++ b/lib/datasource/helm/index.spec.ts @@ -22,6 +22,11 @@ describe(getName(), () => { ).toBeNull(); }); it('returns null if repository was not provided', async () => { + // FIXME: should it call default rtegisty? + httpMock + .scope('https://charts.helm.sh') + .get('/stable/index.yaml') + .reply(404); expect( await getPkgReleases({ datasource: HelmDatasource.id, diff --git a/lib/datasource/packagist/index.spec.ts b/lib/datasource/packagist/index.spec.ts index 4e7e13b990b7da55fe718eddfa26754d6095ccf6..57f7536b4356b6d717d28599184c25aa1adda839 100644 --- a/lib/datasource/packagist/index.spec.ts +++ b/lib/datasource/packagist/index.spec.ts @@ -33,6 +33,10 @@ describe(getName(), () => { }); it('supports custom registries', async () => { + httpMock + .scope('https://composer.renovatebot.com') + .get('/packages.json') + .reply(404); config = { registryUrls: ['https://composer.renovatebot.com'], }; @@ -44,6 +48,7 @@ describe(getName(), () => { }); expect(res).toBeNull(); }); + it('supports plain packages', async () => { const packagesOnly = { packages: { diff --git a/lib/datasource/pod/index.spec.ts b/lib/datasource/pod/index.spec.ts index 66db34635dfcf591fdf4f3a939f0a829f5dbddb7..b2463733383be47046d5bfb93a4b40e3fedeb011 100644 --- a/lib/datasource/pod/index.spec.ts +++ b/lib/datasource/pod/index.spec.ts @@ -22,6 +22,11 @@ describe(getName(), () => { }); it('returns null for invalid inputs', async () => { + // FIXME: why get request? + httpMock + .scope(cocoapodsHost) + .get('/all_pods_versions_3_8_5.txt') + .reply(404); expect( await getPkgReleases({ datasource: pod.id, @@ -31,6 +36,11 @@ describe(getName(), () => { ).toBeNull(); }); it('returns null for empty result', async () => { + // FIXME: why get request? + httpMock + .scope(cocoapodsHost) + .get('/all_pods_versions_a_c_b.txt') + .reply(404); expect(await getPkgReleases(config)).toBeNull(); }); it('returns null for 404', async () => { diff --git a/lib/datasource/rubygems/index.spec.ts b/lib/datasource/rubygems/index.spec.ts index 83a07492d79242680eba26d0d6408eeaa5480b51..8d935229cc9000fef8b75fc995f5eec03cf361c5 100644 --- a/lib/datasource/rubygems/index.spec.ts +++ b/lib/datasource/rubygems/index.spec.ts @@ -167,6 +167,10 @@ describe(getName(), () => { .reply(200, railsInfo) .get('/api/v1/versions/rails.json') .reply(500, {}); + httpMock + .scope('https://firstparty.com/basepath') + .get('/api/v1/gems/rails.json') + .reply(500); expect(await getPkgReleases(params)).toBeNull(); }); }); diff --git a/lib/manager/bazel/update.spec.ts b/lib/manager/bazel/update.spec.ts index 3be8723119eef1616a846b125910dd5f1e1331fc..9d5e913d1a0cd2df2b6bdf14c61453f2f3955c78 100644 --- a/lib/manager/bazel/update.spec.ts +++ b/lib/manager/bazel/update.spec.ts @@ -193,6 +193,12 @@ describe(getName(), () => { currentValue: '0.6.0', newValue: '0.8.0', }; + + httpMock + .scope('https://github.com') + .get('/bazelbuild/bazel-skyfoo/archive/0.8.0.tar.gz') + .reply(500); + const res = await updateDependency({ fileContent: content, upgrade, diff --git a/lib/platform/bitbucket/index.spec.ts b/lib/platform/bitbucket/index.spec.ts index cad5cd8e664161534fadf850457a76b141c14599..993a936f9f076371ff2cad0c15138638e1c94f84 100644 --- a/lib/platform/bitbucket/index.spec.ts +++ b/lib/platform/bitbucket/index.spec.ts @@ -100,6 +100,7 @@ describe(getName(), () => { ); }); it('should init', async () => { + httpMock.scope(baseUrl).get('/2.0/user').reply(200); expect( await bitbucket.initPlatform({ username: 'abc', @@ -611,6 +612,10 @@ describe(getName(), () => { describe('ensureComment()', () => { it('does not throw', async () => { + httpMock + .scope(baseUrl) + .get('/2.0/repositories/undefined/pullrequests/3/comments?pagelen=100') + .reply(500); expect( await bitbucket.ensureComment({ number: 3, @@ -623,6 +628,10 @@ describe(getName(), () => { describe('ensureCommentRemoval()', () => { it('does not throw', async () => { + httpMock + .scope(baseUrl) + .get('/2.0/repositories/undefined/pullrequests/3/comments?pagelen=100') + .reply(500); expect( await bitbucket.ensureCommentRemoval({ number: 3, topic: 'topic' }) ).toMatchSnapshot(); diff --git a/lib/platform/gitlab/index.spec.ts b/lib/platform/gitlab/index.spec.ts index 63c849fe3148aa50a68c57e220ca5c48e3c41203..4cbe3169ceb201e035103a5def5ba3ab6000e27a 100644 --- a/lib/platform/gitlab/index.spec.ts +++ b/lib/platform/gitlab/index.spec.ts @@ -1028,7 +1028,9 @@ describe(getName(), () => { .get('/api/v4/users?username=someuser') .reply(200, [{ id: 1 }]) .get('/api/v4/users?username=someotheruser') - .reply(200, [{ id: 2 }]); + .reply(200, [{ id: 2 }]) + .put('/api/v4/projects/undefined/merge_requests/42') + .reply(200); await gitlab.addReviewers(42, ['someuser', 'foo', 'someotheruser']); expect(scope.isDone()).toBeTrue(); diff --git a/lib/util/merge-confidence/index.spec.ts b/lib/util/merge-confidence/index.spec.ts index ca3eda4652a82821411050bd8c4af33a2ed1dc51..99f6d009e0520963711d66f92e4a76ddc67720a0 100644 --- a/lib/util/merge-confidence/index.spec.ts +++ b/lib/util/merge-confidence/index.spec.ts @@ -162,6 +162,14 @@ describe(getName(), () => { 'minor' ) ).toBe('neutral'); + + // FIXME: no cache hit + httpMock + .scope('https://badges.renovateapi.com') + .get( + `/packages/${datasource}/${depName}-new/${newVersion}/confidence.api/${currentVersion}` + ) + .reply(403); // memory cache expect( await getMergeConfidenceLevel( diff --git a/lib/workers/pr/changelog/github.spec.ts b/lib/workers/pr/changelog/github.spec.ts index 0280a83bf9dc408faa2a27b317d9a1220f264403..19cec8280c715f557105ce65cf79a5d917e66159 100644 --- a/lib/workers/pr/changelog/github.spec.ts +++ b/lib/workers/pr/changelog/github.spec.ts @@ -1,3 +1,4 @@ +import * as httpMock from '../../../../test/http-mock'; import { getName } from '../../../../test/util'; import { PLATFORM_TYPE_GITHUB } from '../../../constants/platforms'; import * as hostRules from '../../../util/host-rules'; @@ -30,6 +31,11 @@ const upgrade: BranchUpgradeConfig = { }; describe(getName(), () => { + afterEach(() => { + // FIXME: add missing http mocks + httpMock.clear(false); + }); + describe('getChangeLogJSON', () => { beforeEach(() => { hostRules.clear(); @@ -39,6 +45,7 @@ describe(getName(), () => { token: 'abc', }); }); + it('returns null if @types', async () => { expect( await getChangeLogJSON({ @@ -47,6 +54,7 @@ describe(getName(), () => { }) ).toBeNull(); }); + it('returns null if no currentVersion', async () => { expect( await getChangeLogJSON({ @@ -55,6 +63,7 @@ describe(getName(), () => { }) ).toBeNull(); }); + it('returns null if currentVersion equals newVersion', async () => { expect( await getChangeLogJSON({ @@ -64,6 +73,7 @@ describe(getName(), () => { }) ).toBeNull(); }); + it('skips invalid repos', async () => { expect( await getChangeLogJSON({ @@ -72,6 +82,7 @@ describe(getName(), () => { }) ).toBeNull(); }); + it('works without Github', async () => { // FIXME: explicit assert condition expect( @@ -80,6 +91,7 @@ describe(getName(), () => { }) ).toMatchSnapshot(); }); + it('uses GitHub tags', async () => { // FIXME: explicit assert condition expect( @@ -88,6 +100,7 @@ describe(getName(), () => { }) ).toMatchSnapshot(); }); + it('filters unnecessary warns', async () => { // FIXME: explicit assert condition expect( @@ -97,6 +110,7 @@ describe(getName(), () => { }) ).toMatchSnapshot(); }); + it('supports node engines', async () => { // FIXME: explicit assert condition expect( @@ -106,6 +120,7 @@ describe(getName(), () => { }) ).toMatchSnapshot(); }); + it('handles no sourceUrl', async () => { expect( await getChangeLogJSON({ @@ -114,6 +129,7 @@ describe(getName(), () => { }) ).toBeNull(); }); + it('handles invalid sourceUrl', async () => { expect( await getChangeLogJSON({ @@ -122,6 +138,7 @@ describe(getName(), () => { }) ).toBeNull(); }); + it('handles missing Github token', async () => { expect( await getChangeLogJSON({ @@ -130,6 +147,7 @@ describe(getName(), () => { }) ).toEqual({ error: ChangeLogError.MissingGithubToken }); }); + it('handles no releases', async () => { expect( await getChangeLogJSON({ @@ -138,6 +156,7 @@ describe(getName(), () => { }) ).toBeNull(); }); + it('handles not enough releases', async () => { expect( await getChangeLogJSON({ @@ -146,6 +165,7 @@ describe(getName(), () => { }) ).toBeNull(); }); + it('supports github enterprise and github.com changelog', async () => { hostRules.add({ hostType: PLATFORM_TYPE_GITHUB, @@ -160,6 +180,7 @@ describe(getName(), () => { }) ).toMatchSnapshot(); }); + it('supports github enterprise and github enterprise changelog', async () => { hostRules.add({ hostType: PLATFORM_TYPE_GITHUB, diff --git a/lib/workers/pr/changelog/gitlab.spec.ts b/lib/workers/pr/changelog/gitlab.spec.ts index 7885d932abcee82755c9b4871b6bd74947ca7da9..4a74ab94d1224317aebea7bddc98e948918502c0 100644 --- a/lib/workers/pr/changelog/gitlab.spec.ts +++ b/lib/workers/pr/changelog/gitlab.spec.ts @@ -32,6 +32,11 @@ const upgrade: BranchUpgradeConfig = { const matchHost = 'https://gitlab.com/'; describe(getName(), () => { + afterEach(() => { + // FIXME: add missing http mocks + httpMock.clear(false); + }); + describe('getChangeLogJSON', () => { beforeEach(() => { hostRules.clear(); diff --git a/lib/workers/pr/changelog/index.spec.ts b/lib/workers/pr/changelog/index.spec.ts index 34193a687e23ab96499e768f660e34ae9bec96ad..85a2f07cf8a61e63988a1c2aa709669d7dd1684c 100644 --- a/lib/workers/pr/changelog/index.spec.ts +++ b/lib/workers/pr/changelog/index.spec.ts @@ -147,6 +147,8 @@ describe(getName(), () => { depType: 'engines', }) ).toMatchSnapshot(); + // FIXME: missing mocks + httpMock.clear(false); }); it('handles no sourceUrl', async () => { expect( diff --git a/lib/workers/pr/changelog/release-notes.spec.ts b/lib/workers/pr/changelog/release-notes.spec.ts index 8753b2062849bb36c0150dba94deb2e62f02b2c3..766afc35bb78b4537a6d88208410b18ff0b8ba2e 100644 --- a/lib/workers/pr/changelog/release-notes.spec.ts +++ b/lib/workers/pr/changelog/release-notes.spec.ts @@ -228,6 +228,11 @@ describe(getName(), () => { it.each([[''], ['v'], ['other-']])( 'gets null from repository without gitlab/github in domain %s', async (prefix) => { + // FIXME: Should not call `api.lol.lol` ? + httpMock + .scope('https://api.lol.lol') + .get('/repos/some/other-repository/releases?per_page=100') + .reply(404); const res = await getReleaseNotes( 'some/other-repository', '1.0.1', @@ -241,6 +246,7 @@ describe(getName(), () => { }); describe('getReleaseNotesMd()', () => { it('handles not found', async () => { + httpMock.scope('https://api.github.com').get('/repos/chalk').reply(404); const res = await getReleaseNotesMd( 'chalk', '2.0.0', diff --git a/test/http-mock.ts b/test/http-mock.ts index 321d6517d0e6f6359ac36bf0af415c2bb39f2506..76e455aba410bb221e44489824697ba39620a5d5 100644 --- a/test/http-mock.ts +++ b/test/http-mock.ts @@ -46,11 +46,15 @@ export function clear(throwOnPending = true): void { const pending = nock.pendingMocks(); nock.abortPendingRequests(); nock.cleanAll(); + const missing = missingLog; requestLog = []; missingLog = []; if (!isDone && throwOnPending) { throw new Error(`Pending mocks!\n * ${pending.join('\n * ')}`); } + if (missing.length && throwOnPending) { + throw new Error(`Missing mocks!\n * ${missing.join('\n * ')}`); + } } export function scope(basePath: BasePath, options?: nock.Options): nock.Scope {