From 7caac0987c11c8ebcf3f72722b4cac8b3227113c Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Tue, 12 May 2020 19:21:14 +0200 Subject: [PATCH] chore: better runCache import --- lib/config/presets/github/index.spec.ts | 4 ++-- lib/datasource/docker/index.spec.ts | 6 +++--- lib/datasource/npm/index.spec.ts | 4 ++-- lib/datasource/packagist/index.spec.ts | 4 ++-- lib/datasource/pod/index.spec.ts | 4 ++-- lib/datasource/rubygems/index.spec.ts | 4 ++-- lib/manager/gradle-wrapper/artifacts.spec.ts | 4 ++-- lib/platform/github/index.spec.ts | 4 ++-- lib/util/cache/run.spec.ts | 8 ++++---- lib/util/got/index.spec.ts | 6 +++--- lib/util/http/github.spec.ts | 4 ++-- lib/workers/repository/process/lookup/index.spec.ts | 4 ++-- 12 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/config/presets/github/index.spec.ts b/lib/config/presets/github/index.spec.ts index 6c125f9963..f84c1de6e8 100644 --- a/lib/config/presets/github/index.spec.ts +++ b/lib/config/presets/github/index.spec.ts @@ -2,7 +2,7 @@ import { mocked } from '../../../../test/util'; import { PLATFORM_FAILURE } from '../../../constants/error-messages'; import { GotResponse } from '../../../platform'; import * as globalCache from '../../../util/cache/global'; -import { clear } from '../../../util/cache/run'; +import * as runCache from '../../../util/cache/run'; import _got from '../../../util/got'; import * as _hostRules from '../../../util/host-rules'; import * as github from '.'; @@ -21,7 +21,7 @@ describe('config/presets/github', () => { }); describe('fetchJSONFile()', () => { beforeEach(() => { - clear(); + runCache.clear(); }); it('returns JSON', async () => { hostRules.find.mockReturnValueOnce({ token: 'abc' }); diff --git a/lib/datasource/docker/index.spec.ts b/lib/datasource/docker/index.spec.ts index 1f43eb7a45..299b6e93b1 100644 --- a/lib/datasource/docker/index.spec.ts +++ b/lib/datasource/docker/index.spec.ts @@ -3,7 +3,7 @@ import AWSMock from 'aws-sdk-mock'; import { getPkgReleases } from '..'; import { DATASOURCE_FAILURE } from '../../constants/error-messages'; import * as globalCache from '../../util/cache/global'; -import { clear } from '../../util/cache/run'; +import * as runCache from '../../util/cache/run'; import _got from '../../util/got'; import * as _hostRules from '../../util/host-rules'; import * as docker from '.'; @@ -31,7 +31,7 @@ describe('api/docker', () => { describe('getDigest', () => { beforeEach(() => { jest.resetAllMocks(); - clear(); + runCache.clear(); hostRules.find.mockReturnValue({ username: 'some-username', password: 'some-password', @@ -281,7 +281,7 @@ describe('api/docker', () => { describe('getReleases', () => { beforeEach(() => { jest.clearAllMocks(); - clear(); + runCache.clear(); return globalCache.rmAll(); }); it('returns null if no token', async () => { diff --git a/lib/datasource/npm/index.spec.ts b/lib/datasource/npm/index.spec.ts index 28a459063f..4e05002ee0 100644 --- a/lib/datasource/npm/index.spec.ts +++ b/lib/datasource/npm/index.spec.ts @@ -4,7 +4,7 @@ import _registryAuthToken from 'registry-auth-token'; import { getName } from '../../../test/util'; import { DATASOURCE_FAILURE } from '../../constants/error-messages'; import * as globalCache from '../../util/cache/global'; -import { clear } from '../../util/cache/run'; +import * as runCache from '../../util/cache/run'; import * as hostRules from '../../util/host-rules'; import * as npm from '.'; @@ -27,7 +27,7 @@ describe(getName(__filename), () => { delete process.env.NPM_TOKEN; beforeEach(() => { jest.resetAllMocks(); - clear(); + runCache.clear(); global.trustLevel = 'low'; npm.resetCache(); npm.setNpmrc(); diff --git a/lib/datasource/packagist/index.spec.ts b/lib/datasource/packagist/index.spec.ts index 6892d3b329..8b056ddaf4 100644 --- a/lib/datasource/packagist/index.spec.ts +++ b/lib/datasource/packagist/index.spec.ts @@ -1,6 +1,6 @@ import fs from 'fs'; import * as globalCache from '../../util/cache/global'; -import { clear } from '../../util/cache/run'; +import * as runCache from '../../util/cache/run'; import _got from '../../util/got'; import * as _hostRules from '../../util/host-rules'; import * as composerVersioning from '../../versioning/composer'; @@ -29,7 +29,7 @@ describe('datasource/packagist', () => { jest.resetAllMocks(); hostRules.find = jest.fn((input) => input); hostRules.hosts = jest.fn(() => []); - clear(); + runCache.clear(); config = { versioning: composerVersioning.id, registryUrls: [ diff --git a/lib/datasource/pod/index.spec.ts b/lib/datasource/pod/index.spec.ts index 6e86043b60..49c6500254 100644 --- a/lib/datasource/pod/index.spec.ts +++ b/lib/datasource/pod/index.spec.ts @@ -3,7 +3,7 @@ import { mocked } from '../../../test/util'; import { GotResponse } from '../../platform'; import { api as _api } from '../../platform/github/gh-got-wrapper'; import * as globalCache from '../../util/cache/global'; -import { clear } from '../../util/cache/run'; +import * as runCache from '../../util/cache/run'; import * as rubyVersioning from '../../versioning/ruby'; import * as pod from '.'; @@ -22,7 +22,7 @@ describe('datasource/cocoapods', () => { describe('getReleases', () => { beforeEach(() => { jest.resetAllMocks(); - clear(); + runCache.clear(); return globalCache.rmAll(); }); diff --git a/lib/datasource/rubygems/index.spec.ts b/lib/datasource/rubygems/index.spec.ts index b3047628db..143e9a6f1e 100644 --- a/lib/datasource/rubygems/index.spec.ts +++ b/lib/datasource/rubygems/index.spec.ts @@ -1,5 +1,5 @@ import { getPkgReleases } from '..'; -import { clear } from '../../util/cache/run'; +import * as runCache from '../../util/cache/run'; import _got from '../../util/got'; import * as rubyVersioning from '../../versioning/ruby'; import railsInfo from './__fixtures__/rails/info.json'; @@ -46,7 +46,7 @@ describe('datasource/rubygems', () => { }); afterEach(() => { - clear(); + runCache.clear(); process.env.RENOVATE_SKIP_CACHE = SKIP_CACHE; }); diff --git a/lib/manager/gradle-wrapper/artifacts.spec.ts b/lib/manager/gradle-wrapper/artifacts.spec.ts index a1916f6374..2b89c65435 100644 --- a/lib/manager/gradle-wrapper/artifacts.spec.ts +++ b/lib/manager/gradle-wrapper/artifacts.spec.ts @@ -9,7 +9,7 @@ import { platform, } from '../../../test/util'; import { setUtilConfig } from '../../util'; -import { clear } from '../../util/cache/run'; +import * as runCache from '../../util/cache/run'; import { ifSystemSupportsGradle } from '../gradle/__testutil__/gradle'; import * as dcUpdate from '.'; @@ -43,7 +43,7 @@ describe(getName(__filename), () => { jest.resetAllMocks(); await setUtilConfig(config); httpMock.setup(); - clear(); + runCache.clear(); }); afterEach(async () => { diff --git a/lib/platform/github/index.spec.ts b/lib/platform/github/index.spec.ts index 3456d492ad..c651112481 100644 --- a/lib/platform/github/index.spec.ts +++ b/lib/platform/github/index.spec.ts @@ -7,7 +7,7 @@ import { REPOSITORY_RENAMED, } from '../../constants/error-messages'; import { BranchStatus } from '../../types'; -import { clear } from '../../util/cache/run'; +import * as runCache from '../../util/cache/run'; import { Platform } from '../common'; const githubApiHost = 'https://api.github.com'; @@ -57,7 +57,7 @@ describe('platform/github', () => { afterEach(() => { httpMock.reset(); - clear(); + runCache.clear(); }); const graphqlOpenPullRequests = fs.readFileSync( diff --git a/lib/util/cache/run.spec.ts b/lib/util/cache/run.spec.ts index 22009941c2..68611a5612 100644 --- a/lib/util/cache/run.spec.ts +++ b/lib/util/cache/run.spec.ts @@ -1,11 +1,11 @@ -import { clear, get, set } from './run'; +import * as runCache from './run'; describe('getRepoCache', () => { it('sets and gets repo cache', () => { - set('key', 'value'); - expect(get('key')).toEqual('value'); + runCache.set('key', 'value'); + expect(runCache.get('key')).toEqual('value'); }); it('clears repo cache', () => { - clear(); + runCache.clear(); }); }); diff --git a/lib/util/got/index.spec.ts b/lib/util/got/index.spec.ts index 104dbb2668..a5f76e9a2f 100644 --- a/lib/util/got/index.spec.ts +++ b/lib/util/got/index.spec.ts @@ -5,7 +5,7 @@ import { PLATFORM_TYPE_GITHUB, PLATFORM_TYPE_GITLAB, } from '../../constants/platforms'; -import { clear } from '../cache/run'; +import * as runCache from '../cache/run'; import * as hostRules from '../host-rules'; import { GotJSONOptions } from './common'; import { api } from '.'; @@ -20,7 +20,7 @@ describe(getName(__filename), () => { afterEach(() => { nock.cleanAll(); hostRules.clear(); - clear(); + runCache.clear(); nock.enableNetConnect(); }); @@ -97,7 +97,7 @@ describe(getName(__filename), () => { await got({ hostType: PLATFORM_TYPE_GITHUB, method: 'HEAD' }) ).toMatchSnapshot(); - clear(); + runCache.clear(); await expect(got({ hostType: PLATFORM_TYPE_GITHUB })).rejects.toThrowError( 'not-found' diff --git a/lib/util/http/github.spec.ts b/lib/util/http/github.spec.ts index 9c80c7724c..3e9847d252 100644 --- a/lib/util/http/github.spec.ts +++ b/lib/util/http/github.spec.ts @@ -8,7 +8,7 @@ import { PLATFORM_RATE_LIMIT_EXCEEDED, REPOSITORY_CHANGED, } from '../../constants/error-messages'; -import { clear } from '../cache/run'; +import * as runCache from '../cache/run'; import { GithubHttp, handleGotError, setBaseUrl } from './github'; const githubApiHost = 'https://api.github.com'; @@ -27,7 +27,7 @@ describe(getName(__filename), () => { afterEach(() => { httpMock.reset(); - clear(); + runCache.clear(); }); describe('HTTP', () => { diff --git a/lib/workers/repository/process/lookup/index.spec.ts b/lib/workers/repository/process/lookup/index.spec.ts index fa032dc2cf..f4f377c7cd 100644 --- a/lib/workers/repository/process/lookup/index.spec.ts +++ b/lib/workers/repository/process/lookup/index.spec.ts @@ -14,7 +14,7 @@ import * as datasourceGithubTags from '../../../../datasource/github-tags'; import * as datasourceNpm from '../../../../datasource/npm'; import * as datasourcePackagist from '../../../../datasource/packagist'; import * as datasourcePypi from '../../../../datasource/pypi'; -import { clear } from '../../../../util/cache/run'; +import * as runCache from '../../../../util/cache/run'; import * as dockerVersioning from '../../../../versioning/docker'; import * as gitVersioning from '../../../../versioning/git'; import * as npmVersioning from '../../../../versioning/npm'; @@ -39,7 +39,7 @@ describe('workers/repository/process/lookup', () => { config.manager = 'npm'; config.versioning = npmVersioning.id; config.rangeStrategy = 'replace'; - clear(); + runCache.clear(); jest.resetAllMocks(); }); -- GitLab