Skip to content

Commit

Permalink
test(datasource/crate): Add missing httpMock.setup/reset() calls (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Feb 6, 2021
1 parent 1beaaa7 commit 4238736
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 252 deletions.
252 changes: 0 additions & 252 deletions lib/datasource/crate/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
},
]
`;

Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions lib/datasource/crate/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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({
Expand Down

0 comments on commit 4238736

Please sign in to comment.