diff --git a/lib/datasource/crate/__snapshots__/index.spec.ts.snap b/lib/datasource/crate/__snapshots__/index.spec.ts.snap index 1030faab7da9cfb50bf51ec3a702a9f55f9782a8..c1ab37f758ccfd002fa6bfa152ee4591ef84101a 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 afbec9411c2ae449591a56b9d34b085804c82172..e39e2612b82baf1e3a53399440d96a7f0efa805a 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({