2020-05-07 08:23:45 +00:00
|
|
|
import { mocked, partial } from '../../../test/util';
|
2020-05-01 16:03:48 +00:00
|
|
|
import { getConfig } from '../../config/defaults';
|
2020-03-05 20:57:24 +00:00
|
|
|
import { PLATFORM_TYPE_GITLAB } from '../../constants/platforms';
|
2020-05-01 16:03:48 +00:00
|
|
|
import { Pr, platform as _platform } from '../../platform';
|
|
|
|
import { BranchStatus } from '../../types';
|
2020-05-07 08:23:45 +00:00
|
|
|
import { BranchConfig, PrResult } from '../common';
|
2020-05-01 16:03:48 +00:00
|
|
|
import * as _changelogHelper from './changelog';
|
2020-04-18 13:36:38 +00:00
|
|
|
import { getChangeLogJSON } from './changelog';
|
2020-05-30 05:15:08 +00:00
|
|
|
import * as codeOwners from './code-owners';
|
2020-05-01 16:03:48 +00:00
|
|
|
import * as prWorker from '.';
|
2019-12-04 03:29:27 +00:00
|
|
|
|
2020-05-30 05:15:08 +00:00
|
|
|
const codeOwnersMock = mocked(codeOwners);
|
2019-12-04 03:29:27 +00:00
|
|
|
const changelogHelper = mocked(_changelogHelper);
|
2020-05-28 10:56:17 +00:00
|
|
|
const gitlabChangelogHelper = mocked(_changelogHelper);
|
2019-12-04 03:29:27 +00:00
|
|
|
const platform = mocked(_platform);
|
|
|
|
const defaultConfig = getConfig();
|
2017-02-14 07:08:40 +00:00
|
|
|
|
2020-03-05 20:57:24 +00:00
|
|
|
jest.mock('./changelog');
|
2020-05-30 05:15:08 +00:00
|
|
|
jest.mock('./code-owners');
|
2019-07-17 08:14:56 +00:00
|
|
|
|
2020-02-01 07:50:24 +00:00
|
|
|
function setupChangelogMock() {
|
|
|
|
changelogHelper.getChangeLogJSON = jest.fn();
|
|
|
|
const resultValue = {
|
|
|
|
project: {
|
2020-04-24 08:42:02 +00:00
|
|
|
baseUrl: 'https://github.com/',
|
2020-02-01 07:50:24 +00:00
|
|
|
github: 'renovateapp/dummy',
|
|
|
|
repository: 'https://github.com/renovateapp/dummy',
|
|
|
|
},
|
|
|
|
hasReleaseNotes: true,
|
|
|
|
versions: [
|
|
|
|
{
|
|
|
|
date: new Date('2017-01-01'),
|
|
|
|
version: '1.1.0',
|
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
date: new Date('2017-01-01'),
|
|
|
|
sha: 'abcdefghijklmnopqrstuvwxyz',
|
|
|
|
message: 'foo #3\nbar',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
releaseNotes: {
|
|
|
|
url: 'https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0',
|
|
|
|
},
|
|
|
|
compare: {
|
|
|
|
url: 'https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0',
|
2017-06-13 09:08:37 +00:00
|
|
|
},
|
2018-05-01 09:55:40 +00:00
|
|
|
},
|
2020-02-01 07:50:24 +00:00
|
|
|
],
|
|
|
|
};
|
|
|
|
const errorValue = {
|
|
|
|
error: _changelogHelper.ChangeLogError.MissingGithubToken,
|
|
|
|
};
|
|
|
|
changelogHelper.getChangeLogJSON.mockResolvedValueOnce(resultValue);
|
|
|
|
changelogHelper.getChangeLogJSON.mockResolvedValueOnce(errorValue);
|
|
|
|
changelogHelper.getChangeLogJSON.mockResolvedValue(resultValue);
|
|
|
|
}
|
2017-02-14 07:08:40 +00:00
|
|
|
|
2020-05-28 10:56:17 +00:00
|
|
|
function setupGitlabChangelogMock() {
|
|
|
|
gitlabChangelogHelper.getChangeLogJSON = jest.fn();
|
|
|
|
const resultValue = {
|
|
|
|
project: {
|
|
|
|
baseUrl: 'https://gitlab.com/',
|
|
|
|
gitlab: 'renovateapp/gitlabdummy',
|
|
|
|
repository: 'https://gitlab.com/renovateapp/gitlabdummy',
|
|
|
|
},
|
|
|
|
hasReleaseNotes: true,
|
|
|
|
versions: [
|
|
|
|
{
|
|
|
|
date: new Date('2017-01-01'),
|
|
|
|
version: '1.1.0',
|
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
date: new Date('2017-01-01'),
|
|
|
|
sha: 'abcdefghijklmnopqrstuvwxyz',
|
|
|
|
message: 'foo #3\nbar',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
releaseNotes: {
|
|
|
|
url:
|
|
|
|
'https://gitlab.com/renovateapp/gitlabdummy/compare/v1.0.0...v1.1.0',
|
|
|
|
},
|
|
|
|
compare: {
|
|
|
|
url:
|
|
|
|
'https://gitlab.com/renovateapp/gitlabdummy/compare/v1.0.0...v1.1.0',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
const errorValue = {
|
|
|
|
error: _changelogHelper.ChangeLogError.MissingGithubToken,
|
|
|
|
};
|
|
|
|
gitlabChangelogHelper.getChangeLogJSON.mockResolvedValueOnce(resultValue);
|
|
|
|
gitlabChangelogHelper.getChangeLogJSON.mockResolvedValueOnce(errorValue);
|
|
|
|
gitlabChangelogHelper.getChangeLogJSON.mockResolvedValue(resultValue);
|
|
|
|
}
|
|
|
|
|
2017-02-14 07:08:40 +00:00
|
|
|
describe('workers/pr', () => {
|
2017-11-08 05:44:03 +00:00
|
|
|
describe('checkAutoMerge(pr, config)', () => {
|
2020-05-07 08:23:45 +00:00
|
|
|
let config: BranchConfig;
|
|
|
|
let pr: Pr;
|
2017-04-20 11:01:23 +00:00
|
|
|
beforeEach(() => {
|
2020-05-07 08:23:45 +00:00
|
|
|
config = partial<BranchConfig>({
|
2017-08-26 14:10:18 +00:00
|
|
|
...defaultConfig,
|
2020-05-07 08:23:45 +00:00
|
|
|
});
|
|
|
|
pr = partial<Pr>({
|
2018-02-27 18:50:16 +00:00
|
|
|
canMerge: true,
|
2020-05-07 08:23:45 +00:00
|
|
|
});
|
2017-04-20 11:01:23 +00:00
|
|
|
});
|
2017-11-07 10:46:10 +00:00
|
|
|
afterEach(() => {
|
|
|
|
jest.clearAllMocks();
|
|
|
|
});
|
2017-04-20 11:01:23 +00:00
|
|
|
it('should not automerge if not configured', async () => {
|
2017-11-08 05:44:03 +00:00
|
|
|
await prWorker.checkAutoMerge(pr, config);
|
2019-04-02 14:59:27 +00:00
|
|
|
expect(platform.mergePr).toHaveBeenCalledTimes(0);
|
2017-04-20 11:01:23 +00:00
|
|
|
});
|
2017-06-08 04:18:21 +00:00
|
|
|
it('should automerge if enabled and pr is mergeable', async () => {
|
2017-08-21 11:41:48 +00:00
|
|
|
config.automerge = true;
|
2019-08-29 08:30:17 +00:00
|
|
|
pr.isModified = false;
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green);
|
2019-12-04 03:29:27 +00:00
|
|
|
platform.mergePr.mockResolvedValueOnce(true);
|
2017-11-08 05:44:03 +00:00
|
|
|
await prWorker.checkAutoMerge(pr, config);
|
2019-04-02 14:59:27 +00:00
|
|
|
expect(platform.mergePr).toHaveBeenCalledTimes(1);
|
2017-04-20 11:01:23 +00:00
|
|
|
});
|
2018-05-04 04:55:01 +00:00
|
|
|
it('should automerge comment', async () => {
|
|
|
|
config.automerge = true;
|
|
|
|
config.automergeType = 'pr-comment';
|
|
|
|
config.automergeComment = '!merge';
|
2019-08-29 08:30:17 +00:00
|
|
|
pr.isModified = false;
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green);
|
2018-05-04 04:55:01 +00:00
|
|
|
await prWorker.checkAutoMerge(pr, config);
|
2020-05-14 11:13:38 +00:00
|
|
|
expect(platform.ensureCommentRemoval).toHaveBeenCalledTimes(0);
|
|
|
|
expect(platform.ensureComment).toHaveBeenCalledTimes(1);
|
|
|
|
});
|
|
|
|
it('should remove previous automerge comment when rebasing', async () => {
|
|
|
|
config.automerge = true;
|
|
|
|
config.automergeType = 'pr-comment';
|
|
|
|
config.automergeComment = '!merge';
|
|
|
|
config.rebaseRequested = true;
|
|
|
|
pr.isModified = false;
|
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green);
|
|
|
|
await prWorker.checkAutoMerge(pr, config);
|
|
|
|
expect(platform.ensureCommentRemoval).toHaveBeenCalledTimes(1);
|
2019-04-02 14:59:27 +00:00
|
|
|
expect(platform.ensureComment).toHaveBeenCalledTimes(1);
|
2018-05-04 04:55:01 +00:00
|
|
|
});
|
2017-08-21 09:17:47 +00:00
|
|
|
it('should not automerge if enabled and pr is mergeable but cannot rebase', async () => {
|
2017-08-21 11:41:48 +00:00
|
|
|
config.automerge = true;
|
2019-08-29 08:30:17 +00:00
|
|
|
pr.isModified = true;
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green);
|
2017-11-08 05:44:03 +00:00
|
|
|
await prWorker.checkAutoMerge(pr, config);
|
2019-04-02 14:59:27 +00:00
|
|
|
expect(platform.mergePr).toHaveBeenCalledTimes(0);
|
2017-08-21 09:17:47 +00:00
|
|
|
});
|
2017-06-08 04:18:21 +00:00
|
|
|
it('should not automerge if enabled and pr is mergeable but branch status is not success', async () => {
|
2017-08-21 11:41:48 +00:00
|
|
|
config.automerge = true;
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.yellow);
|
2017-11-08 05:44:03 +00:00
|
|
|
await prWorker.checkAutoMerge(pr, config);
|
2019-04-02 14:59:27 +00:00
|
|
|
expect(platform.mergePr).toHaveBeenCalledTimes(0);
|
2017-04-20 11:01:23 +00:00
|
|
|
});
|
2017-06-08 04:18:21 +00:00
|
|
|
it('should not automerge if enabled and pr is mergeable but unstable', async () => {
|
2017-08-21 11:41:48 +00:00
|
|
|
config.automerge = true;
|
2018-02-27 18:50:16 +00:00
|
|
|
pr.canMerge = undefined;
|
2017-11-08 05:44:03 +00:00
|
|
|
await prWorker.checkAutoMerge(pr, config);
|
2019-04-02 14:59:27 +00:00
|
|
|
expect(platform.mergePr).toHaveBeenCalledTimes(0);
|
2017-04-20 11:01:23 +00:00
|
|
|
});
|
2017-06-08 04:18:21 +00:00
|
|
|
it('should not automerge if enabled and pr is unmergeable', async () => {
|
2017-08-21 11:41:48 +00:00
|
|
|
config.automerge = true;
|
2018-09-14 18:02:51 +00:00
|
|
|
pr.isConflicted = true;
|
2017-11-08 05:44:03 +00:00
|
|
|
await prWorker.checkAutoMerge(pr, config);
|
2019-04-02 14:59:27 +00:00
|
|
|
expect(platform.mergePr).toHaveBeenCalledTimes(0);
|
2017-04-20 11:01:23 +00:00
|
|
|
});
|
|
|
|
});
|
2017-08-26 14:10:18 +00:00
|
|
|
describe('ensurePr', () => {
|
2020-05-07 08:23:45 +00:00
|
|
|
let config: BranchConfig;
|
2019-12-04 03:29:27 +00:00
|
|
|
// TODO fix type
|
|
|
|
const existingPr: Pr = {
|
2017-11-08 10:09:26 +00:00
|
|
|
displayNumber: 'Existing PR',
|
|
|
|
title: 'Update dependency dummy to v1.1.0',
|
2018-06-19 13:15:13 +00:00
|
|
|
body:
|
|
|
|
'Some body<!-- Reviewable:start -->something<!-- Reviewable:end -->\n\n',
|
2019-08-29 08:30:17 +00:00
|
|
|
isModified: false,
|
2019-12-04 03:29:27 +00:00
|
|
|
} as never;
|
2017-02-14 07:08:40 +00:00
|
|
|
beforeEach(() => {
|
2020-02-01 07:50:24 +00:00
|
|
|
setupChangelogMock();
|
2020-05-07 08:23:45 +00:00
|
|
|
config = partial<BranchConfig>({
|
2017-08-26 14:10:18 +00:00
|
|
|
...defaultConfig,
|
2020-05-07 08:23:45 +00:00
|
|
|
});
|
2017-11-08 10:09:26 +00:00
|
|
|
config.branchName = 'renovate/dummy-1.x';
|
|
|
|
config.prTitle = 'Update dependency dummy to v1.1.0';
|
2018-09-21 03:43:51 +00:00
|
|
|
config.depType = 'devDependencies';
|
2017-11-08 10:09:26 +00:00
|
|
|
config.depName = 'dummy';
|
|
|
|
config.privateRepo = true;
|
2019-06-01 06:23:18 +00:00
|
|
|
config.displayFrom = '1.0.0';
|
|
|
|
config.displayTo = '1.1.0';
|
2018-09-21 07:46:51 +00:00
|
|
|
config.updateType = 'minor';
|
2018-09-21 03:43:51 +00:00
|
|
|
config.homepage = 'https://dummy.com';
|
2018-12-10 04:59:28 +00:00
|
|
|
config.sourceUrl = 'https://github.com/renovateapp/dummy';
|
2019-01-22 06:37:51 +00:00
|
|
|
config.sourceDirectory = 'packages/a';
|
2018-09-21 03:43:51 +00:00
|
|
|
config.changelogUrl = 'https://github.com/renovateapp/dummy/changelog.md';
|
2019-12-04 03:29:27 +00:00
|
|
|
// TODO fix type
|
|
|
|
platform.createPr.mockResolvedValue({
|
|
|
|
displayNumber: 'New Pull Request',
|
|
|
|
} as never);
|
2017-07-07 09:45:48 +00:00
|
|
|
config.upgrades = [config];
|
2020-04-12 16:09:36 +00:00
|
|
|
platform.getPrBody = jest.fn((input) => input);
|
2018-10-29 05:32:20 +00:00
|
|
|
platform.getBranchPr = jest.fn();
|
|
|
|
platform.getBranchStatus = jest.fn();
|
2017-02-14 07:08:40 +00:00
|
|
|
});
|
2017-11-07 10:46:10 +00:00
|
|
|
afterEach(() => {
|
|
|
|
jest.clearAllMocks();
|
|
|
|
});
|
2017-02-14 07:08:40 +00:00
|
|
|
it('should return null if check fails', async () => {
|
2018-01-19 04:46:28 +00:00
|
|
|
platform.updatePr.mockImplementationOnce(() => {
|
2017-02-14 07:08:40 +00:00
|
|
|
throw new Error('oops');
|
|
|
|
});
|
2018-06-04 03:48:20 +00:00
|
|
|
config.newValue = '1.2.0';
|
2019-12-04 03:29:27 +00:00
|
|
|
platform.getBranchPr.mockResolvedValueOnce(existingPr);
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Error);
|
2020-03-10 08:16:11 +00:00
|
|
|
expect(pr).toBeUndefined();
|
2017-02-14 07:08:40 +00:00
|
|
|
});
|
2017-04-20 10:11:56 +00:00
|
|
|
it('should return null if waiting for success', async () => {
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.red);
|
2017-04-20 10:11:56 +00:00
|
|
|
config.prCreation = 'status-success';
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.AwaitingGreenBranch);
|
2020-03-10 08:16:11 +00:00
|
|
|
expect(pr).toBeUndefined();
|
2017-04-20 10:11:56 +00:00
|
|
|
});
|
2019-07-11 11:48:41 +00:00
|
|
|
it('should return needs-approval if prCreation set to approval', async () => {
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green);
|
2019-07-11 11:48:41 +00:00
|
|
|
config.prCreation = 'approval';
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.AwaitingApproval);
|
2020-03-10 08:16:11 +00:00
|
|
|
expect(pr).toBeUndefined();
|
2019-07-11 11:48:41 +00:00
|
|
|
});
|
2020-05-28 10:56:17 +00:00
|
|
|
it('should create PR if success for gitlab deps', async () => {
|
|
|
|
setupGitlabChangelogMock();
|
|
|
|
config.branchName = 'renovate/gitlabdummy-1.x';
|
|
|
|
config.depName = 'gitlabdummy';
|
|
|
|
config.sourceUrl = 'https://gitlab.com/renovateapp/gitlabdummy';
|
|
|
|
config.changelogUrl =
|
|
|
|
'https://gitlab.com/renovateapp/gitlabdummy/changelog.md';
|
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green);
|
|
|
|
config.prCreation = 'status-success';
|
|
|
|
config.automerge = true;
|
|
|
|
config.schedule = ['before 5am'];
|
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
|
|
|
expect(platform.createPr.mock.calls[0]).toMatchSnapshot();
|
|
|
|
existingPr.body = platform.createPr.mock.calls[0][0].prBody;
|
|
|
|
config.branchName = 'renovate/dummy-1.x';
|
|
|
|
config.depName = 'dummy';
|
|
|
|
config.sourceUrl = 'https://github.com/renovateapp/dummy';
|
|
|
|
config.changelogUrl = 'https://github.com/renovateapp/dummy/changelog.md';
|
|
|
|
});
|
2017-04-20 10:11:56 +00:00
|
|
|
it('should create PR if success', async () => {
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green);
|
2020-04-18 13:36:38 +00:00
|
|
|
config.logJSON = await getChangeLogJSON(config);
|
2017-04-20 10:11:56 +00:00
|
|
|
config.prCreation = 'status-success';
|
2018-09-21 03:43:51 +00:00
|
|
|
config.automerge = true;
|
2020-05-07 08:23:45 +00:00
|
|
|
config.schedule = ['before 5am'];
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2017-04-20 10:11:56 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
2017-11-08 10:09:26 +00:00
|
|
|
expect(platform.createPr.mock.calls[0]).toMatchSnapshot();
|
2020-01-07 15:33:19 +00:00
|
|
|
existingPr.body = platform.createPr.mock.calls[0][0].prBody;
|
2017-11-08 10:09:26 +00:00
|
|
|
});
|
2018-09-21 03:43:51 +00:00
|
|
|
it('should create group PR', async () => {
|
|
|
|
config.upgrades = config.upgrades.concat([
|
|
|
|
{
|
|
|
|
depName: 'a',
|
2019-06-01 06:23:18 +00:00
|
|
|
displayFrom: 'zzzzzz',
|
|
|
|
displayTo: 'aaaaaaa',
|
2018-09-21 09:36:07 +00:00
|
|
|
prBodyNotes: ['note 1', 'note 2'],
|
2018-09-21 03:43:51 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
depName: 'b',
|
|
|
|
newDigestShort: 'bbbbbbb',
|
2019-06-01 06:23:18 +00:00
|
|
|
displayFrom: 'some_old_value',
|
|
|
|
displayTo: 'some_new_value',
|
2018-09-21 03:43:51 +00:00
|
|
|
updateType: 'pin',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
depName: 'c',
|
|
|
|
gitRef: 'ccccccc',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
depName: 'd',
|
|
|
|
updateType: 'lockFileMaintenance',
|
2018-09-21 09:36:07 +00:00
|
|
|
prBodyNotes: ['{{#if foo}}'],
|
2018-09-21 03:43:51 +00:00
|
|
|
},
|
2020-05-07 08:23:45 +00:00
|
|
|
] as never);
|
2018-09-21 03:43:51 +00:00
|
|
|
config.updateType = 'lockFileMaintenance';
|
|
|
|
config.recreateClosed = true;
|
2020-02-22 15:31:50 +00:00
|
|
|
config.rebaseWhen = 'never';
|
2020-04-18 13:36:38 +00:00
|
|
|
for (const upgrade of config.upgrades) {
|
|
|
|
upgrade.logJSON = await getChangeLogJSON(upgrade);
|
|
|
|
}
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2018-09-21 03:43:51 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
|
|
|
expect(platform.createPr.mock.calls[0]).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
it('should add note about Pin', async () => {
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green);
|
2018-09-21 03:43:51 +00:00
|
|
|
config.prCreation = 'status-success';
|
|
|
|
config.isPin = true;
|
2018-09-21 07:46:51 +00:00
|
|
|
config.updateType = 'pin';
|
2020-05-07 08:23:45 +00:00
|
|
|
config.schedule = ['before 5am'];
|
2018-09-21 03:43:51 +00:00
|
|
|
config.timezone = 'some timezone';
|
2020-02-22 15:31:50 +00:00
|
|
|
config.rebaseWhen = 'behind-base-branch';
|
2020-04-18 13:36:38 +00:00
|
|
|
config.logJSON = await getChangeLogJSON(config);
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2018-09-21 03:43:51 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
|
|
|
expect(platform.createPr.mock.calls[0]).toMatchSnapshot();
|
2020-05-18 12:33:44 +00:00
|
|
|
expect(platform.createPr.mock.calls[0][0].prBody).toContain(
|
|
|
|
'this Pin PR'
|
|
|
|
);
|
2018-09-21 03:43:51 +00:00
|
|
|
});
|
2017-11-28 16:11:52 +00:00
|
|
|
it('should return null if creating PR fails', async () => {
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green);
|
2017-11-10 14:02:25 +00:00
|
|
|
platform.createPr = jest.fn();
|
2017-11-07 10:46:10 +00:00
|
|
|
platform.createPr.mockImplementationOnce(() => {
|
2018-02-07 07:05:32 +00:00
|
|
|
throw new Error('Validation Failed (422)');
|
2017-09-03 08:02:48 +00:00
|
|
|
});
|
|
|
|
config.prCreation = 'status-success';
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Error);
|
2020-03-10 08:16:11 +00:00
|
|
|
expect(pr).toBeUndefined();
|
2017-09-03 08:02:48 +00:00
|
|
|
});
|
2017-04-20 10:11:56 +00:00
|
|
|
it('should return null if waiting for not pending', async () => {
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.yellow);
|
2019-12-04 03:29:27 +00:00
|
|
|
platform.getBranchLastCommitTime.mockImplementationOnce(() =>
|
|
|
|
Promise.resolve(new Date())
|
|
|
|
);
|
2017-04-20 10:11:56 +00:00
|
|
|
config.prCreation = 'not-pending';
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.AwaitingNotPending);
|
2020-03-10 08:16:11 +00:00
|
|
|
expect(pr).toBeUndefined();
|
2017-04-20 10:11:56 +00:00
|
|
|
});
|
2017-08-28 09:37:09 +00:00
|
|
|
it('should create PR if pending timeout hit', async () => {
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.yellow);
|
2019-12-04 03:29:27 +00:00
|
|
|
platform.getBranchLastCommitTime.mockImplementationOnce(() =>
|
|
|
|
Promise.resolve(new Date('2017-01-01'))
|
2017-08-28 09:37:09 +00:00
|
|
|
);
|
|
|
|
config.prCreation = 'not-pending';
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2017-08-28 09:37:09 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
|
|
|
});
|
2017-04-20 10:11:56 +00:00
|
|
|
it('should create PR if no longer pending', async () => {
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.red);
|
2017-04-20 10:11:56 +00:00
|
|
|
config.prCreation = 'not-pending';
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2017-04-20 10:11:56 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
|
|
|
});
|
2017-02-14 07:08:40 +00:00
|
|
|
it('should create new branch if none exists', async () => {
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2017-02-14 07:08:40 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
|
|
|
});
|
|
|
|
it('should add assignees and reviewers to new PR', async () => {
|
2017-08-01 04:58:13 +00:00
|
|
|
config.assignees = ['@foo', 'bar'];
|
|
|
|
config.reviewers = ['baz', '@boo'];
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2017-02-14 07:08:40 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
2019-04-02 14:59:27 +00:00
|
|
|
expect(platform.addAssignees).toHaveBeenCalledTimes(1);
|
2017-11-07 10:46:10 +00:00
|
|
|
expect(platform.addAssignees.mock.calls).toMatchSnapshot();
|
2019-04-02 14:59:27 +00:00
|
|
|
expect(platform.addReviewers).toHaveBeenCalledTimes(1);
|
2017-11-07 10:46:10 +00:00
|
|
|
expect(platform.addReviewers.mock.calls).toMatchSnapshot();
|
2017-04-21 05:23:36 +00:00
|
|
|
});
|
2020-05-30 05:15:08 +00:00
|
|
|
it('should determine assignees from code owners', async () => {
|
|
|
|
config.assigneesFromCodeOwners = true;
|
|
|
|
codeOwnersMock.codeOwnersForPr.mockResolvedValueOnce(['@john', '@maria']);
|
|
|
|
await prWorker.ensurePr(config);
|
|
|
|
expect(platform.addAssignees).toHaveBeenCalledTimes(1);
|
|
|
|
expect(platform.addAssignees.mock.calls).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
it('should determine reviewers from code owners', async () => {
|
|
|
|
config.reviewersFromCodeOwners = true;
|
|
|
|
codeOwnersMock.codeOwnersForPr.mockResolvedValueOnce(['@john', '@maria']);
|
|
|
|
await prWorker.ensurePr(config);
|
|
|
|
expect(platform.addReviewers).toHaveBeenCalledTimes(1);
|
|
|
|
expect(platform.addReviewers.mock.calls).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
it('should combine assignees from code owners and config', async () => {
|
|
|
|
codeOwnersMock.codeOwnersForPr.mockResolvedValueOnce(['@jimmy']);
|
|
|
|
config.assignees = ['@mike', '@julie'];
|
|
|
|
config.assigneesFromCodeOwners = true;
|
|
|
|
await prWorker.ensurePr(config);
|
|
|
|
expect(platform.addAssignees).toHaveBeenCalledTimes(1);
|
|
|
|
expect(platform.addAssignees.mock.calls).toMatchSnapshot();
|
|
|
|
});
|
2017-08-24 08:14:53 +00:00
|
|
|
it('should add reviewers even if assignees fails', async () => {
|
2017-11-07 10:46:10 +00:00
|
|
|
platform.addAssignees.mockImplementationOnce(() => {
|
2017-08-24 08:14:53 +00:00
|
|
|
throw new Error('some error');
|
|
|
|
});
|
|
|
|
config.assignees = ['@foo', 'bar'];
|
|
|
|
config.reviewers = ['baz', '@boo'];
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2017-08-24 08:14:53 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
2019-04-02 14:59:27 +00:00
|
|
|
expect(platform.addAssignees).toHaveBeenCalledTimes(1);
|
|
|
|
expect(platform.addReviewers).toHaveBeenCalledTimes(1);
|
2017-08-24 08:14:53 +00:00
|
|
|
});
|
|
|
|
it('should handled failed reviewers add', async () => {
|
2017-11-07 10:46:10 +00:00
|
|
|
platform.addReviewers.mockImplementationOnce(() => {
|
2017-08-24 08:14:53 +00:00
|
|
|
throw new Error('some error');
|
|
|
|
});
|
|
|
|
config.assignees = ['@foo', 'bar'];
|
|
|
|
config.reviewers = ['baz', '@boo'];
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2017-08-24 08:14:53 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
2019-04-02 14:59:27 +00:00
|
|
|
expect(platform.addAssignees).toHaveBeenCalledTimes(1);
|
|
|
|
expect(platform.addReviewers).toHaveBeenCalledTimes(1);
|
2017-08-24 08:14:53 +00:00
|
|
|
});
|
2020-03-08 14:03:19 +00:00
|
|
|
it('should not add assignees and reviewers to new PR if automerging enabled regularly', async () => {
|
2017-04-21 05:23:36 +00:00
|
|
|
config.assignees = ['bar'];
|
|
|
|
config.reviewers = ['baz'];
|
2017-08-21 11:41:48 +00:00
|
|
|
config.automerge = true;
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2017-04-21 05:23:36 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
2019-04-02 14:59:27 +00:00
|
|
|
expect(platform.addAssignees).toHaveBeenCalledTimes(0);
|
|
|
|
expect(platform.addReviewers).toHaveBeenCalledTimes(0);
|
2017-04-21 05:23:36 +00:00
|
|
|
});
|
2019-08-06 09:21:44 +00:00
|
|
|
it('should add assignees and reviewers to new PR if automerging enabled but configured to always assign', async () => {
|
|
|
|
config.assignees = ['bar'];
|
|
|
|
config.reviewers = ['baz'];
|
|
|
|
config.automerge = true;
|
|
|
|
config.assignAutomerge = true;
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2019-08-06 09:21:44 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
|
|
|
expect(platform.addAssignees).toHaveBeenCalledTimes(1);
|
|
|
|
expect(platform.addReviewers).toHaveBeenCalledTimes(1);
|
|
|
|
});
|
2019-09-22 07:19:26 +00:00
|
|
|
it('should add random sample of assignees and reviewers to new PR', async () => {
|
|
|
|
config.assignees = ['foo', 'bar', 'baz'];
|
|
|
|
config.assigneesSampleSize = 2;
|
|
|
|
config.reviewers = ['baz', 'boo', 'bor'];
|
|
|
|
config.reviewersSampleSize = 2;
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2020-03-10 08:16:11 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
2019-09-22 07:19:26 +00:00
|
|
|
expect(platform.addAssignees).toHaveBeenCalledTimes(1);
|
|
|
|
const assignees = platform.addAssignees.mock.calls[0][1];
|
2020-05-18 12:33:44 +00:00
|
|
|
expect(assignees).toHaveLength(2);
|
2019-09-22 07:19:26 +00:00
|
|
|
expect(config.assignees).toEqual(expect.arrayContaining(assignees));
|
|
|
|
|
|
|
|
expect(platform.addReviewers).toHaveBeenCalledTimes(1);
|
|
|
|
const reviewers = platform.addReviewers.mock.calls[0][1];
|
2020-05-18 12:33:44 +00:00
|
|
|
expect(reviewers).toHaveLength(2);
|
2019-09-22 07:19:26 +00:00
|
|
|
expect(config.reviewers).toEqual(expect.arrayContaining(reviewers));
|
|
|
|
});
|
2020-01-15 03:32:31 +00:00
|
|
|
it('should add and deduplicate additionalReviewers on new PR', async () => {
|
|
|
|
config.reviewers = ['@foo', 'bar'];
|
|
|
|
config.additionalReviewers = ['bar', 'baz', '@boo'];
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2020-01-15 03:32:31 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
|
|
|
expect(platform.addReviewers).toHaveBeenCalledTimes(1);
|
|
|
|
expect(platform.addReviewers.mock.calls).toMatchSnapshot();
|
|
|
|
});
|
2017-02-14 07:08:40 +00:00
|
|
|
it('should return unmodified existing PR', async () => {
|
2019-12-04 03:29:27 +00:00
|
|
|
platform.getBranchPr.mockResolvedValueOnce(existingPr);
|
2017-11-24 06:14:58 +00:00
|
|
|
config.semanticCommitScope = null;
|
2018-09-21 03:43:51 +00:00
|
|
|
config.automerge = true;
|
2020-05-07 08:23:45 +00:00
|
|
|
config.schedule = ['before 5am'];
|
2020-04-18 13:36:38 +00:00
|
|
|
config.logJSON = await getChangeLogJSON(config);
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.NotUpdated);
|
2017-11-07 10:46:10 +00:00
|
|
|
expect(platform.updatePr.mock.calls).toMatchSnapshot();
|
2019-04-02 14:59:27 +00:00
|
|
|
expect(platform.updatePr).toHaveBeenCalledTimes(0);
|
2017-02-14 07:08:40 +00:00
|
|
|
expect(pr).toMatchObject(existingPr);
|
|
|
|
});
|
2018-12-05 04:58:02 +00:00
|
|
|
it('should return unmodified existing PR if only whitespace changes', async () => {
|
|
|
|
const modifiedPr = JSON.parse(
|
2020-04-12 16:09:36 +00:00
|
|
|
JSON.stringify(existingPr).replace(' ', ' ').replace('\n', '\r\n')
|
2018-12-05 04:58:02 +00:00
|
|
|
);
|
2019-12-04 03:29:27 +00:00
|
|
|
platform.getBranchPr.mockResolvedValueOnce(modifiedPr);
|
2018-12-05 04:58:02 +00:00
|
|
|
config.semanticCommitScope = null;
|
|
|
|
config.automerge = true;
|
2020-05-07 08:23:45 +00:00
|
|
|
config.schedule = ['before 5am'];
|
2020-04-18 13:36:38 +00:00
|
|
|
config.logJSON = await getChangeLogJSON(config);
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.NotUpdated);
|
2019-04-02 14:59:27 +00:00
|
|
|
expect(platform.updatePr).toHaveBeenCalledTimes(0);
|
2018-12-05 04:58:02 +00:00
|
|
|
expect(pr).toMatchObject(modifiedPr);
|
|
|
|
});
|
2017-02-14 07:08:40 +00:00
|
|
|
it('should return modified existing PR', async () => {
|
2018-06-04 03:48:20 +00:00
|
|
|
config.newValue = '1.2.0';
|
2018-09-21 03:43:51 +00:00
|
|
|
config.automerge = true;
|
2020-05-07 08:23:45 +00:00
|
|
|
config.schedule = ['before 5am'];
|
2020-04-18 13:36:38 +00:00
|
|
|
config.logJSON = await getChangeLogJSON(config);
|
2019-12-04 03:29:27 +00:00
|
|
|
platform.getBranchPr.mockResolvedValueOnce(existingPr);
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.NotUpdated);
|
2017-08-03 06:01:20 +00:00
|
|
|
expect(pr).toMatchSnapshot();
|
2017-02-14 07:08:40 +00:00
|
|
|
});
|
2018-01-28 20:41:42 +00:00
|
|
|
it('should return modified existing PR title', async () => {
|
2018-06-04 03:48:20 +00:00
|
|
|
config.newValue = '1.2.0';
|
2019-12-04 03:29:27 +00:00
|
|
|
platform.getBranchPr.mockResolvedValueOnce({
|
2018-01-28 20:41:42 +00:00
|
|
|
...existingPr,
|
|
|
|
title: 'wrong',
|
|
|
|
});
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Updated);
|
2018-01-28 20:41:42 +00:00
|
|
|
expect(pr).toMatchSnapshot();
|
|
|
|
});
|
2017-10-05 07:31:10 +00:00
|
|
|
it('should create PR if branch tests failed', async () => {
|
2017-08-21 11:41:48 +00:00
|
|
|
config.automerge = true;
|
2018-06-26 11:51:50 +00:00
|
|
|
config.automergeType = 'branch';
|
2018-06-07 12:42:51 +00:00
|
|
|
config.branchAutomergeFailureMessage = 'branch status error';
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.red);
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2017-06-08 04:18:21 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
|
|
|
});
|
2017-10-05 07:31:10 +00:00
|
|
|
it('should create PR if branch automerging failed', async () => {
|
|
|
|
config.automerge = true;
|
2018-06-26 11:51:50 +00:00
|
|
|
config.automergeType = 'branch';
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green);
|
2017-10-05 07:31:10 +00:00
|
|
|
config.forcePr = true;
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2017-10-05 07:31:10 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
|
|
|
});
|
2020-03-10 08:16:11 +00:00
|
|
|
it('should return no PR if branch automerging not failed', async () => {
|
2017-08-21 11:41:48 +00:00
|
|
|
config.automerge = true;
|
2018-06-26 11:51:50 +00:00
|
|
|
config.automergeType = 'branch';
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.yellow);
|
2019-12-04 03:29:27 +00:00
|
|
|
platform.getBranchLastCommitTime.mockResolvedValueOnce(new Date());
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
2020-06-26 14:47:24 +00:00
|
|
|
expect(prResult).toEqual(PrResult.BlockedByBranchAutomerge);
|
2020-03-10 08:16:11 +00:00
|
|
|
expect(pr).toBeUndefined();
|
2017-06-08 04:18:21 +00:00
|
|
|
});
|
2020-03-10 08:16:11 +00:00
|
|
|
it('should not return no PR if branch automerging taking too long', async () => {
|
2018-02-09 12:29:47 +00:00
|
|
|
config.automerge = true;
|
2018-06-26 11:51:50 +00:00
|
|
|
config.automergeType = 'branch';
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.yellow);
|
2019-12-04 03:29:27 +00:00
|
|
|
platform.getBranchLastCommitTime.mockResolvedValueOnce(
|
2018-02-09 12:29:47 +00:00
|
|
|
new Date('2018-01-01')
|
|
|
|
);
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2020-03-10 08:16:11 +00:00
|
|
|
expect(pr).toBeDefined();
|
2018-02-09 12:29:47 +00:00
|
|
|
});
|
2017-06-22 19:35:32 +00:00
|
|
|
it('handles duplicate upgrades', async () => {
|
2017-07-07 09:45:48 +00:00
|
|
|
config.upgrades.push(config.upgrades[0]);
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2017-06-22 19:35:32 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
|
|
|
});
|
2018-02-01 10:36:30 +00:00
|
|
|
it('should create privateRepo PR if success', async () => {
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green);
|
2018-02-01 10:36:30 +00:00
|
|
|
config.prCreation = 'status-success';
|
|
|
|
config.privateRepo = false;
|
2020-04-18 13:36:38 +00:00
|
|
|
config.logJSON = await getChangeLogJSON(config);
|
2020-05-28 11:17:22 +00:00
|
|
|
config.logJSON.project.gitlab = 'someproject';
|
|
|
|
delete config.logJSON.project.github;
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2018-02-01 10:36:30 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
|
|
|
expect(platform.createPr.mock.calls[0]).toMatchSnapshot();
|
2020-01-07 15:33:19 +00:00
|
|
|
existingPr.body = platform.createPr.mock.calls[0][0].prBody;
|
2018-02-01 10:36:30 +00:00
|
|
|
});
|
2019-02-08 13:31:30 +00:00
|
|
|
it('should create PR if waiting for not pending but artifactErrors', async () => {
|
2020-03-08 14:03:19 +00:00
|
|
|
platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.yellow);
|
2019-12-04 03:29:27 +00:00
|
|
|
platform.getBranchLastCommitTime.mockResolvedValueOnce(new Date());
|
2018-03-15 06:06:18 +00:00
|
|
|
config.prCreation = 'not-pending';
|
2019-02-08 13:31:30 +00:00
|
|
|
config.artifactErrors = [{}];
|
2020-01-17 07:26:42 +00:00
|
|
|
config.platform = PLATFORM_TYPE_GITLAB;
|
2020-03-10 09:02:02 +00:00
|
|
|
const { prResult, pr } = await prWorker.ensurePr(config);
|
|
|
|
expect(prResult).toEqual(PrResult.Created);
|
2018-03-15 06:06:18 +00:00
|
|
|
expect(pr).toMatchObject({ displayNumber: 'New Pull Request' });
|
|
|
|
});
|
2019-10-05 08:00:32 +00:00
|
|
|
|
|
|
|
it('should trigger GitLab automerge when configured', async () => {
|
|
|
|
config.gitLabAutomerge = true;
|
|
|
|
config.automerge = true;
|
|
|
|
await prWorker.ensurePr(config);
|
|
|
|
const args = platform.createPr.mock.calls[0];
|
2020-01-07 15:33:19 +00:00
|
|
|
expect(args[0].platformOptions).toMatchObject({
|
2019-10-05 08:00:32 +00:00
|
|
|
gitLabAutomerge: true,
|
|
|
|
});
|
|
|
|
});
|
2017-02-14 07:08:40 +00:00
|
|
|
});
|
|
|
|
});
|