From 4bed9fea46d06389ce47a009a049f02f3aac8d10 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Wed, 6 Sep 2023 21:24:57 +1000 Subject: [PATCH] Fix tests --- node-src/git/getCommitAndBranch.test.ts | 10 +++++++++- node-src/git/getCommitAndBranch.ts | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/node-src/git/getCommitAndBranch.test.ts b/node-src/git/getCommitAndBranch.test.ts index 07f40cc60..4e1ac288a 100644 --- a/node-src/git/getCommitAndBranch.test.ts +++ b/node-src/git/getCommitAndBranch.test.ts @@ -87,11 +87,19 @@ describe('getCommitAndBranch', () => { expect(info).toMatchObject({ branch: 'master' }); }); - it('throws when there is only one commit', async () => { + it('throws when there is only one commit, CI', async () => { + envCi.mockReturnValue({ isCi: true }); hasPreviousCommit.mockResolvedValue(false); await expect(getCommitAndBranch({ log })).rejects.toThrow('Found only one commit'); }); + it('does NOT throw when there is only one commit, non-CI', async () => { + envCi.mockReturnValue({ isCi: false }); + hasPreviousCommit.mockResolvedValue(false); + const info = await getCommitAndBranch({ log }); + expect(info).toMatchObject({}); + }); + describe('with branchName', () => { it('uses provided branchName as branch', async () => { const info = await getCommitAndBranch({ log }, { branchName: 'foobar' }); diff --git a/node-src/git/getCommitAndBranch.ts b/node-src/git/getCommitAndBranch.ts index c0649a779..4f20ac369 100644 --- a/node-src/git/getCommitAndBranch.ts +++ b/node-src/git/getCommitAndBranch.ts @@ -21,7 +21,7 @@ interface CommitInfo { } export default async function getCommitAndBranch( - { log, options }, + { log }, { branchName, patchBaseRef,