Select Git revision
tutorial-server-secrets.html
dependency-dashboard.spec.ts 17.31 KiB
import { ERROR, WARN } from 'bunyan';
import { mock } from 'jest-mock-extended';
import {
RenovateConfig,
getConfig,
getName,
loadFixture,
logger,
platform,
} from '../../../test/util';
import { setAdminConfig } from '../../config/admin';
import { PLATFORM_TYPE_GITHUB } from '../../constants/platforms';
import { Platform, Pr } from '../../platform';
import { PrState } from '../../types';
import { BranchConfig, BranchResult, BranchUpgradeConfig } from '../types';
import * as dependencyDashboard from './dependency-dashboard';
type PrUpgrade = BranchUpgradeConfig;
let config: RenovateConfig;
beforeEach(() => {
jest.clearAllMocks();
config = getConfig();
config.platform = PLATFORM_TYPE_GITHUB;
config.errors = [];
config.warnings = [];
});
async function dryRun(
branches: BranchConfig[],
// eslint-disable-next-line @typescript-eslint/no-shadow
platform: jest.Mocked<Platform>,
ensureIssueClosingCalls = 0,
ensureIssueCalls = 0,
getBranchPrCalls = 0,
findPrCalls = 0
) {
jest.clearAllMocks();
setAdminConfig({ dryRun: true });
await dependencyDashboard.ensureMasterIssue(config, branches);
expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(
ensureIssueClosingCalls
);
expect(platform.ensureIssue).toHaveBeenCalledTimes(ensureIssueCalls);
expect(platform.getBranchPr).toHaveBeenCalledTimes(getBranchPrCalls);
expect(platform.findPr).toHaveBeenCalledTimes(findPrCalls);
}
describe(getName(), () => {
describe('ensureMasterIssue()', () => {
beforeEach(() => {
setAdminConfig();
});
it('do nothing if masterissue is disable', async () => {
const branches: BranchConfig[] = [];
await dependencyDashboard.ensureMasterIssue(config, branches);
expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(0);
expect(platform.ensureIssue).toHaveBeenCalledTimes(0);
expect(platform.getBranchPr).toHaveBeenCalledTimes(0);
expect(platform.findPr).toHaveBeenCalledTimes(0);
// same with dry run
await dryRun(branches, platform);
});
it('do nothing if it has no masterissueapproval branches', async () => {
const branches = [
{
...mock<BranchConfig>(),
prTitle: 'pr1',