From c2215db9ae4573ad44ad55d6030d072f42038ba0 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Mon, 28 Sep 2026 10:51:26 +0100 Subject: [PATCH] Update `git-utils` tests --- src/git-utils.test.ts | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/git-utils.test.ts b/src/git-utils.test.ts index 6f5f37401..0240a0950 100644 --- a/src/git-utils.test.ts +++ b/src/git-utils.test.ts @@ -34,13 +34,15 @@ test.serial( }); const callback = sinon.stub(gitUtils, "getCommitOid"); - callback.withArgs(sinon.match.string, "HEAD").resolves(currentSha); + callback + .withArgs(sinon.match.any, sinon.match.string, "HEAD") + .resolves(currentSha); const actualRef = await gitUtils.getRef(env, tmpDir); t.deepEqual(actualRef, expectedRef); t.is(callback.callCount, 1); - t.true(callback.calledOnceWith(tmpDir, "HEAD")); + t.true(callback.calledOnceWith(env, tmpDir, "HEAD")); }); }, ); @@ -60,16 +62,22 @@ test.serial( const callback = sinon.stub(gitUtils, "getCommitOid"); callback - .withArgs(sinon.match.string, "refs/remotes/pull/1/merge") + .withArgs( + sinon.match.any, + sinon.match.string, + "refs/remotes/pull/1/merge", + ) + .resolves(sha); + callback + .withArgs(sinon.match.any, sinon.match.string, "HEAD") .resolves(sha); - callback.withArgs(sinon.match.any, "HEAD").resolves(sha); const actualRef = await gitUtils.getRef(env, tmpDir); t.deepEqual(actualRef, expectedRef); t.is(callback.callCount, 2); - t.true(callback.calledWith(tmpDir, "HEAD")); - t.true(callback.calledWith(tmpDir, "refs/remotes/pull/1/merge")); + t.true(callback.calledWith(env, tmpDir, "HEAD")); + t.true(callback.calledWith(env, tmpDir, "refs/remotes/pull/1/merge")); }); }, ); @@ -87,17 +95,19 @@ test.serial( const callback = sinon.stub(gitUtils, "getCommitOid"); callback - .withArgs(tmpDir, "refs/remotes/pull/1/merge") + .withArgs(sinon.match.any, tmpDir, "refs/remotes/pull/1/merge") .resolves("a".repeat(40)); - callback.withArgs(tmpDir, "HEAD").resolves("b".repeat(40)); + callback + .withArgs(sinon.match.any, tmpDir, "HEAD") + .resolves("b".repeat(40)); callback.throws(new Error("Unexpected getCommitOid call in test.")); const actualRef = await gitUtils.getRef(env, tmpDir); t.deepEqual(actualRef, "refs/pull/1/head"); t.is(callback.callCount, 2); - t.true(callback.calledWith(tmpDir, "refs/remotes/pull/1/merge")); - t.true(callback.calledWith(tmpDir, "HEAD")); + t.true(callback.calledWith(env, tmpDir, "refs/remotes/pull/1/merge")); + t.true(callback.calledWith(env, tmpDir, "HEAD")); }); }, ); @@ -122,8 +132,12 @@ test.serial( }); const callback = sinon.stub(gitUtils, "getCommitOid"); - callback.withArgs(tmpDir, "refs/pull/1/merge").resolves("b".repeat(40)); - callback.withArgs(sinon.match.any, "HEAD").resolves("b".repeat(40)); + callback + .withArgs(sinon.match.any, tmpDir, "refs/pull/1/merge") + .resolves("b".repeat(40)); + callback + .withArgs(sinon.match.any, sinon.match.string, "HEAD") + .resolves("b".repeat(40)); const actualRef = await gitUtils.getRef(env, tmpDir); t.deepEqual(actualRef, "refs/pull/2/merge");