Skip to content

Commit 6f63d79

Browse files
Implement test for null head repo
1 parent c6972e4 commit 6f63d79

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

test/autoupdate.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,25 @@ describe('test `handlePullRequest`', () => {
944944
expect(updated).toEqual(false);
945945
expect(updateSpy).toHaveBeenCalledTimes(1);
946946
});
947+
948+
test('pull request head repo is null, should log error and return false', async () => {
949+
const dummyPullRequestEvent = {
950+
action: 'synchronize',
951+
pull_request: {
952+
head: {
953+
repo: null,
954+
},
955+
},
956+
} as any;
957+
const updater = new AutoUpdater(config, dummyPullRequestEvent);
958+
const errorSpy = jest.spyOn(core, 'error').mockImplementation(() => {});
959+
const result = await updater.handlePullRequest();
960+
expect(result).toBe(false);
961+
expect(errorSpy).toHaveBeenCalledWith(
962+
'Pull request head repo is null, skipping update.',
963+
);
964+
errorSpy.mockRestore();
965+
});
947966
});
948967

949968
describe('test `update`', () => {

0 commit comments

Comments
 (0)