From 1719c78fe1e5a3c1e6571f661e7a68edd4b4d289 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Fri, 19 Jul 2024 12:46:37 +1000 Subject: [PATCH] Add test for changes --- node-src/git/findAncestorBuildWithCommit.test.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/node-src/git/findAncestorBuildWithCommit.test.ts b/node-src/git/findAncestorBuildWithCommit.test.ts index cc5a6fa46..f75610a3a 100644 --- a/node-src/git/findAncestorBuildWithCommit.test.ts +++ b/node-src/git/findAncestorBuildWithCommit.test.ts @@ -15,6 +15,7 @@ const makeBuild = (build: Partial = {}): Build => ({ number: 1, commit: 'missing', uncommittedHash: '', + isLocalBuild: false, ...build, }); const makeResult = (ancestorBuilds: Build[]): AncestorBuildsQueryResult => ({ @@ -36,14 +37,24 @@ describe('findAncestorBuildWithCommit', () => { expect(client.runQuery.mock.calls[0][1]).toMatchObject({ buildNumber: 1 }); }); - it('does not return build with uncommitted changes', async () => { + it('does not return a local build with uncommitted changes', async () => { client.runQuery.mockReturnValue( - makeResult([makeBuild({ commit: 'exists', uncommittedHash: 'abc123' })]) + makeResult([makeBuild({ commit: 'exists', uncommittedHash: 'abc123', isLocalBuild: true })]) ); expect(await findAncestorBuildWithCommit({ client }, 1, { page: 1, limit: 1 })).toBeNull(); }); + it('DOES return a CI build with uncommitted changes', async () => { + client.runQuery.mockReturnValue( + makeResult([makeBuild({ commit: 'exists', uncommittedHash: 'abc123' })]) + ); + + expect(await findAncestorBuildWithCommit({ client }, 1, { page: 1, limit: 1 })).toMatchObject({ + commit: 'exists', + }); + }); + it('passes skip and limit and recurse', async () => { const toFind = makeBuild({ number: 3, commit: 'exists' }); client.runQuery