Skip to content

Commit

Permalink
feat: allow unhandle pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentHardouin committed Dec 23, 2024
1 parent f7759ac commit 2493c26
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions build/services/merge-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ export class MergeQueue {
});
await this.handle({ repositoryName });
}

async unhandlePullRequest({ repositoryName, number }) {
await this.#pullRequestRepository.remove({
repositoryName,
number,
});
await this.handle({ repositoryName });
}
}

export const mergeQueue = new MergeQueue({ pullRequestRepository, githubService });
22 changes: 22 additions & 0 deletions test/unit/run/services/merge-queue_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,26 @@ describe('Unit | Build | Services | merge-queue', function () {
expect(mergeQueue.handle).to.have.been.calledOnceWithExactly({ repositoryName });
});
});

describe('#unhandlePullRequest', function () {
it('should remove pr and call handle method', async function () {
const repositoryName = Symbol('repository-name');
const pullRequestNumber = Symbol('pull-request-number');

const pullRequestRepository = {
remove: sinon.stub(),
};

const mergeQueue = new MergeQueue({ pullRequestRepository });
mergeQueue.handle = sinon.stub();

await mergeQueue.unhandlePullRequest({ repositoryName, number: pullRequestNumber });

expect(pullRequestRepository.remove).to.have.been.calledOnceWithExactly({
repositoryName,
number: pullRequestNumber,
});
expect(mergeQueue.handle).to.have.been.calledOnceWithExactly(repositoryName);
});
});
});

0 comments on commit 2493c26

Please sign in to comment.