Skip to content

Commit

Permalink
test: second git error message when deleting branch
Browse files Browse the repository at this point in the history
  • Loading branch information
oatymart committed Sep 11, 2024
1 parent d446a89 commit 36ef73d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/unit/release/removeReleasingBranch/release.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,17 @@ describe('src/release.js removeReleasingBranch', () => {
expect(deleteBranch).toBeCalledWith(`${branchPrefix}-${version}`);
});
test('should bypass error deleting release branch when it does not exist', async () => {
expect.assertions(2);
expect.assertions(4);

const deleteBranch = jest.fn();

deleteBranch.mockImplementationOnce(() => {
throw new Error('remote ref does not exist');
}).mockImplementationOnce(() => {
throw new Error('[remote rejected] (cannot lock ref \'refs/heads/release-4.0.0\': unable to resolve reference \'refs/heads/release-4.0.0\'');
});

git.mockImplementationOnce(() => {
git.mockImplementation(() => {
return {
deleteBranch
};
Expand All @@ -120,6 +122,13 @@ describe('src/release.js removeReleasingBranch', () => {

expect(deleteBranch).toBeCalledTimes(1);
expect(deleteBranch).toBeCalledWith(`${branchPrefix}-${version}`);

deleteBranch.mockClear();

await release.removeReleasingBranch();

expect(deleteBranch).toBeCalledTimes(1);
expect(deleteBranch).toBeCalledWith(`${branchPrefix}-${version}`);
});
test('should not bypass error deleting release branch when another error', async () => {
expect.assertions(3);
Expand Down

0 comments on commit 36ef73d

Please sign in to comment.