From 42387360b3043b141f4fb9ae8b9821b15e67141e Mon Sep 17 00:00:00 2001 From: Tobias Bieniek <tobias.bieniek@gmail.com> Date: Sat, 6 Feb 2021 13:44:31 +0100 Subject: [PATCH] test(datasource/crate): Add missing `httpMock.setup/reset()` calls (#8566) --- .../crate/__snapshots__/index.spec.ts.snap | 252 ------------------ lib/datasource/crate/index.spec.ts | 7 + 2 files changed, 7 insertions(+), 252 deletions(-) diff --git a/lib/datasource/crate/__snapshots__/index.spec.ts.snap b/lib/datasource/crate/__snapshots__/index.spec.ts.snap index 1030faab7d..c1ab37f758 100644 --- a/lib/datasource/crate/__snapshots__/index.spec.ts.snap +++ b/lib/datasource/crate/__snapshots__/index.spec.ts.snap @@ -96,69 +96,6 @@ Object { exports[`datasource/crate getReleases processes real data: amethyst 2`] = ` Array [ - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/so/me/some_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/so/me/some_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/so/me/some_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/li/bc/libc", - }, Object { "headers": Object { "accept-encoding": "gzip, deflate", @@ -378,60 +315,6 @@ Object { exports[`datasource/crate getReleases processes real data: libc 2`] = ` Array [ - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/so/me/some_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/so/me/some_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/so/me/some_crate", - }, Object { "headers": Object { "accept-encoding": "gzip, deflate", @@ -448,33 +331,6 @@ exports[`datasource/crate getReleases refuses to clone if trustLevel is not high exports[`datasource/crate getReleases returns null for 404 1`] = ` Array [ - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, Object { "headers": Object { "accept-encoding": "gzip, deflate", @@ -498,24 +354,6 @@ Array [ "method": "GET", "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, ] `; @@ -544,65 +382,11 @@ Array [ "method": "GET", "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, ] `; exports[`datasource/crate getReleases returns null for unknown error 1`] = ` Array [ - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/so/me/some_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/so/me/some_crate", - }, Object { "headers": Object { "accept-encoding": "gzip, deflate", @@ -619,42 +403,6 @@ exports[`datasource/crate getReleases throws for 5xx 1`] = `[Error: external-hos exports[`datasource/crate getReleases throws for 5xx 2`] = ` Array [ - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/no/n_/non_existent_crate", - }, - Object { - "headers": Object { - "accept-encoding": "gzip, deflate", - "host": "raw.githubusercontent.com", - "user-agent": "https://github.com/renovatebot/renovate", - }, - "method": "GET", - "url": "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/so/me/some_crate", - }, Object { "headers": Object { "accept-encoding": "gzip, deflate", diff --git a/lib/datasource/crate/index.spec.ts b/lib/datasource/crate/index.spec.ts index afbec9411c..e39e2612b8 100644 --- a/lib/datasource/crate/index.spec.ts +++ b/lib/datasource/crate/index.spec.ts @@ -62,7 +62,10 @@ describe('datasource/crate', () => { let tmpDir: DirectoryResult | null; let localDir: string | null; let cacheDir: string | null; + beforeEach(async () => { + httpMock.setup(); + tmpDir = await dir(); localDir = join(tmpDir.path, 'local'); cacheDir = join(tmpDir.path, 'cache'); @@ -74,11 +77,15 @@ describe('datasource/crate', () => { memCache.init(); setAdminConfig(); }); + afterEach(() => { fs.rmdirSync(tmpDir.path, { recursive: true }); tmpDir = null; setAdminConfig(); + + httpMock.reset(); }); + it('returns null for missing registry url', async () => { expect( await getPkgReleases({ -- GitLab