test: add test for tokenless build commit exec

This commit is contained in:
joseph-sentry 2024-07-26 13:54:22 -04:00
parent 58f4498604
commit 0c23ec5ce3
No known key found for this signature in database

View file

@ -307,3 +307,31 @@ test('commit args using github server url', async () => {
expect(commitExecArgs).toEqual(expectedArgs);
expect(commitCommand).toEqual('create-commit');
});
test('get token when token arg is unset and from fork', async () => {
context.eventName = 'pull_request';
context.payload.pull_request = {
'number': 1,
'base': {
'label': 'hello:main',
},
'head': {
'label': 'world:feat',
'sha': 'aaaaaa',
},
};
const expectedArgs: string[] = [
'--git-service',
'github_enterprise',
'-B',
'world:feat',
'-C',
`${context.payload.pull_request?.head.sha}`,
];
const {commitExecArgs, commitCommand} = await buildCommitExec();
expect(commitExecArgs).toEqual(expectedArgs);
expect(commitCommand).toEqual('create-commit');
});