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

View file

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