mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-10 14:06:30 +00:00
refactor(util/exec): change mocked modules in existing tests (#16519)
This commit is contained in:
parent
e10aa6aa5a
commit
6202b1c264
20 changed files with 24 additions and 26 deletions
|
@ -14,7 +14,7 @@ const datasource = mocked(_datasource);
|
|||
const bundlerHostRules = mocked(_bundlerHostRules);
|
||||
|
||||
jest.mock('fs-extra');
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../util/exec/common');
|
||||
jest.mock('../../../util/exec/env');
|
||||
jest.mock('../../datasource');
|
||||
jest.mock('../../../util/fs');
|
||||
|
|
|
@ -7,7 +7,7 @@ import * as docker from '../../../util/exec/docker';
|
|||
import type { UpdateArtifactsConfig } from '../types';
|
||||
import * as cargo from '.';
|
||||
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../util/exec/common');
|
||||
jest.mock('../../../util/exec/env');
|
||||
jest.mock('../../../util/git');
|
||||
jest.mock('../../../util/http');
|
||||
|
|
|
@ -9,7 +9,7 @@ import * as _datasource from '../../datasource';
|
|||
import type { UpdateArtifactsConfig } from '../types';
|
||||
import { updateArtifacts } from '.';
|
||||
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../util/exec/common');
|
||||
jest.mock('../../../util/exec/env');
|
||||
jest.mock('../../../util/git');
|
||||
jest.mock('../../../util/fs');
|
||||
|
|
|
@ -12,7 +12,7 @@ import { PackagistDatasource } from '../../datasource/packagist';
|
|||
import type { UpdateArtifactsConfig } from '../types';
|
||||
import * as composer from '.';
|
||||
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../util/exec/common');
|
||||
jest.mock('../../../util/exec/env');
|
||||
jest.mock('../../datasource');
|
||||
jest.mock('../../../util/fs');
|
||||
|
|
|
@ -3,7 +3,7 @@ import { fs } from '../../../../test/util';
|
|||
import { GlobalConfig } from '../../../config/global';
|
||||
import { updateArtifacts } from '.';
|
||||
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../util/exec/common');
|
||||
jest.mock('../../../util/fs');
|
||||
|
||||
describe('modules/manager/flux/artifacts', () => {
|
||||
|
|
|
@ -10,7 +10,7 @@ import * as _hostRules from '../../../util/host-rules';
|
|||
import type { UpdateArtifactsConfig } from '../types';
|
||||
import * as gomod from '.';
|
||||
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../util/exec/common');
|
||||
jest.mock('../../../util/exec/env');
|
||||
jest.mock('../../../util/git');
|
||||
jest.mock('../../../util/host-rules');
|
||||
|
|
|
@ -17,7 +17,7 @@ import type { StatusResult } from '../../../util/git/types';
|
|||
import type { UpdateArtifactsConfig } from '../types';
|
||||
import * as gradleWrapper from '.';
|
||||
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../util/exec/common');
|
||||
jest.mock('../../../util/fs');
|
||||
jest.mock('../../../util/git');
|
||||
jest.mock('../../../util/exec/env');
|
||||
|
|
|
@ -10,7 +10,7 @@ import * as _datasource from '../../datasource';
|
|||
import type { UpdateArtifactsConfig } from '../types';
|
||||
import * as helmv3 from '.';
|
||||
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../util/exec/common');
|
||||
jest.mock('../../datasource');
|
||||
jest.mock('../../../util/exec/env');
|
||||
jest.mock('../../../util/http');
|
||||
|
|
|
@ -7,7 +7,7 @@ import type { StatusResult } from '../../../util/git/types';
|
|||
import type { UpdateArtifactsConfig } from '../types';
|
||||
import { updateArtifacts } from '.';
|
||||
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../util/exec/common');
|
||||
jest.mock('../../../util/exec/env');
|
||||
jest.mock('../../../util/fs');
|
||||
jest.mock('../../../util/git');
|
||||
|
|
|
@ -7,7 +7,7 @@ import * as docker from '../../../util/exec/docker';
|
|||
import type { UpdateArtifactsConfig } from '../types';
|
||||
import { updateArtifacts } from '.';
|
||||
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../util/exec/common');
|
||||
jest.mock('../../../util/exec/env');
|
||||
jest.mock('../../../util/fs');
|
||||
jest.mock('../../../util/host-rules');
|
||||
|
|
|
@ -5,7 +5,7 @@ import type { RepoGlobalConfig } from '../../../../config/types';
|
|||
import type { PackageFile, PostUpdateConfig } from '../../types';
|
||||
import * as lernaHelper from './lerna';
|
||||
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../../util/exec/common');
|
||||
jest.mock('../../../../util/exec/env');
|
||||
jest.mock('../../npm/post-update/node-version');
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import { env, fs } from '../../../../../test/util';
|
|||
import { GlobalConfig } from '../../../../config/global';
|
||||
import * as npmHelper from './npm';
|
||||
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../../util/exec/common');
|
||||
jest.mock('../../../../util/exec/env');
|
||||
jest.mock('../../../../util/fs');
|
||||
jest.mock('./node-version');
|
||||
|
|
|
@ -5,7 +5,7 @@ import { GlobalConfig } from '../../../../config/global';
|
|||
import type { PostUpdateConfig } from '../../types';
|
||||
import * as pnpmHelper from './pnpm';
|
||||
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../../util/exec/common');
|
||||
jest.mock('../../../../util/exec/env');
|
||||
jest.mock('../../../../util/fs');
|
||||
jest.mock('./node-version');
|
||||
|
|
|
@ -18,7 +18,7 @@ import * as yarnHelper from './yarn';
|
|||
jest.mock('fs-extra', () =>
|
||||
require('../../../../../test/fixtures').Fixtures.fsExtra()
|
||||
);
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../../util/exec/common');
|
||||
jest.mock('../../../../util/exec/env');
|
||||
jest.mock('./node-version');
|
||||
jest.mock('../../../datasource');
|
||||
|
|
|
@ -9,7 +9,7 @@ import type { UpdateArtifactsConfig } from '../types';
|
|||
import * as util from './util';
|
||||
import * as nuget from '.';
|
||||
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../util/exec/common');
|
||||
jest.mock('../../../util/exec/env');
|
||||
jest.mock('../../../util/fs');
|
||||
jest.mock('../../../util/host-rules');
|
||||
|
|
|
@ -13,7 +13,7 @@ import { constructPipCompileCmd } from './artifacts';
|
|||
import { updateArtifacts } from '.';
|
||||
|
||||
jest.mock('fs-extra');
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../util/exec/common');
|
||||
jest.mock('../../../util/exec/env');
|
||||
jest.mock('../../../util/git');
|
||||
jest.mock('../../../util/host-rules');
|
||||
|
|
|
@ -8,7 +8,7 @@ import type { StatusResult } from '../../../util/git/types';
|
|||
import type { UpdateArtifactsConfig } from '../types';
|
||||
import * as pipenv from '.';
|
||||
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../util/exec/common');
|
||||
jest.mock('../../../util/exec/env');
|
||||
jest.mock('../../../util/git');
|
||||
jest.mock('../../../util/fs');
|
||||
|
|
|
@ -15,7 +15,7 @@ const pyproject1toml = Fixtures.get('pyproject.1.toml');
|
|||
const pyproject10toml = Fixtures.get('pyproject.10.toml');
|
||||
|
||||
jest.mock('fs-extra');
|
||||
jest.mock('child_process');
|
||||
jest.mock('../../../util/exec/common');
|
||||
jest.mock('../../../util/exec/env');
|
||||
jest.mock('../../datasource');
|
||||
jest.mock('../../../util/host-rules');
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
resetPrefetchedImages,
|
||||
} from '.';
|
||||
|
||||
jest.mock('child_process');
|
||||
jest.mock('../common');
|
||||
|
||||
const getPkgReleases: jest.Mock<typeof _getPkgReleases> =
|
||||
_getPkgReleases as any;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { exec as _exec } from 'child_process';
|
||||
import is from '@sindresorhus/is';
|
||||
import traverse from 'traverse';
|
||||
import upath from 'upath';
|
||||
import { rawExec as _exec } from '../lib/util/exec/common';
|
||||
import type { ExecOptions } from '../lib/util/exec/types';
|
||||
import { regEx } from '../lib/util/regex';
|
||||
|
||||
|
@ -45,13 +45,12 @@ export function mockExecAll(
|
|||
execResult: ExecResult = defaultExecResult
|
||||
): ExecSnapshots {
|
||||
const snapshots: ExecSnapshots = [];
|
||||
execFn.mockImplementation((cmd, options, callback) => {
|
||||
execFn.mockImplementation((cmd, options) => {
|
||||
snapshots.push(execSnapshot(cmd, options));
|
||||
if (execResult instanceof Error) {
|
||||
throw execResult;
|
||||
}
|
||||
callback(null, execResult);
|
||||
return undefined as never;
|
||||
return execResult as never;
|
||||
});
|
||||
return snapshots;
|
||||
}
|
||||
|
@ -62,13 +61,12 @@ export function mockExecSequence(
|
|||
): ExecSnapshots {
|
||||
const snapshots: ExecSnapshots = [];
|
||||
execResults.forEach((execResult) => {
|
||||
execFn.mockImplementationOnce((cmd, options, callback) => {
|
||||
execFn.mockImplementationOnce((cmd, options) => {
|
||||
snapshots.push(execSnapshot(cmd, options));
|
||||
if (execResult instanceof Error) {
|
||||
throw execResult;
|
||||
}
|
||||
callback(null, execResult);
|
||||
return undefined as never;
|
||||
return execResult as never;
|
||||
});
|
||||
});
|
||||
return snapshots;
|
||||
|
|
Loading…
Reference in a new issue