fix(bitbucket-server): fix race condition (#3592)

This commit is contained in:
Michael Kriese 2019-04-25 14:43:21 +02:00 committed by Rhys Arkins
parent 30fd17779e
commit 5306e6bdf2
2 changed files with 5 additions and 0 deletions

View file

@ -1,4 +1,5 @@
const url = require('url');
const delay = require('delay');
const api = require('./bb-got-wrapper');
const utils = require('./utils');
@ -240,6 +241,8 @@ async function commitFilesToBranch(
parentBranch
);
// wait for pr change propagation
await delay(1000);
// refresh cache
await getBranchPr(branchName, true);
}
@ -696,6 +699,7 @@ async function getPr(prNo, refreshCache) {
if (!prNo) {
return null;
}
const res = await api.get(
`./rest/api/1.0/projects/${config.projectKey}/repos/${
config.repositorySlug

View file

@ -13,6 +13,7 @@ describe('platform/bitbucket-server', () => {
beforeEach(() => {
// reset module
jest.resetModules();
jest.mock('delay');
jest.mock('got', () => (url, options) => {
const { method } = options;
const body = mockResponses[url] && mockResponses[url][method];