scaffolder-backend-module-github: test fix for conditional throw in mock

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-04-20 12:03:39 +02:00
parent 1f2acab2b8
commit bffa8090bd
2 changed files with 12 additions and 4 deletions
@@ -755,8 +755,12 @@ describe('publish:github', () => {
},
});
mockOctokit.rest.teams.addOrUpdateRepoPermissionsInOrg.mockRejectedValueOnce(
new Error('Something bad happened'),
mockOctokit.rest.teams.addOrUpdateRepoPermissionsInOrg.mockImplementation(
async opts => {
if (opts.team_slug === 'robot-1') {
throw Error('Something bad happened');
}
},
);
await action.handler({
@@ -477,8 +477,12 @@ describe('github:repo:create', () => {
},
});
mockOctokit.rest.teams.addOrUpdateRepoPermissionsInOrg.mockRejectedValueOnce(
new Error('Something bad happened'),
mockOctokit.rest.teams.addOrUpdateRepoPermissionsInOrg.mockImplementation(
async opts => {
if (opts.team_slug === 'robot-1') {
throw Error('Something bad happened');
}
},
);
await action.handler({