From 0c23ec5ce3b60858d639965e86841aa9dfc76749 Mon Sep 17 00:00:00 2001 From: joseph-sentry Date: Fri, 26 Jul 2024 13:54:22 -0400 Subject: [PATCH] test: add test for tokenless build commit exec --- src/buildExec.test.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/buildExec.test.ts b/src/buildExec.test.ts index efacf8c..6e0c72d 100644 --- a/src/buildExec.test.ts +++ b/src/buildExec.test.ts @@ -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'); +});