Skip to content

Commit 9c9e4b0

Browse files
committed
Fix getCommitOid stubs
1 parent 41a4b9a commit 9c9e4b0

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

‎src/git-utils.test.ts‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ test.serial(
2929
process.env["GITHUB_SHA"] = currentSha;
3030

3131
const callback = sinon.stub(gitUtils, "getCommitOid");
32-
callback.withArgs("HEAD").resolves(currentSha);
32+
callback.withArgs(sinon.match.string, "HEAD").resolves(currentSha);
3333

3434
const actualRef = await gitUtils.getRef();
3535
t.deepEqual(actualRef, expectedRef);
36+
37+
t.true(callback.calledOnceWith(tmpDir, "HEAD"));
3638
});
3739
},
3840
);
@@ -48,11 +50,15 @@ test.serial(
4850
const sha = "a".repeat(40);
4951

5052
const callback = sinon.stub(gitUtils, "getCommitOid");
51-
callback.withArgs("refs/remotes/pull/1/merge").resolves(sha);
52-
callback.withArgs("HEAD").resolves(sha);
53+
callback
54+
.withArgs(sinon.match.string, "refs/remotes/pull/1/merge")
55+
.resolves(sha);
56+
callback.withArgs(sinon.match.any, "HEAD").resolves(sha);
5357

5458
const actualRef = await gitUtils.getRef();
5559
t.deepEqual(actualRef, expectedRef);
60+
61+
t.true(callback.calledWith(tmpDir, "refs/remotes/pull/1/merge"));
5662
});
5763
},
5864
);
@@ -71,6 +77,9 @@ test.serial(
7177

7278
const actualRef = await gitUtils.getRef();
7379
t.deepEqual(actualRef, "refs/pull/1/head");
80+
81+
t.true(callback.calledOnceWith(tmpDir, "refs/pull/1/merge"));
82+
t.true(callback.calledOnceWith(tmpDir, "HEAD"));
7483
});
7584
},
7685
);
@@ -92,11 +101,14 @@ test.serial(
92101
process.env["GITHUB_SHA"] = "a".repeat(40);
93102

94103
const callback = sinon.stub(gitUtils, "getCommitOid");
95-
callback.withArgs("refs/pull/1/merge").resolves("b".repeat(40));
96-
callback.withArgs("HEAD").resolves("b".repeat(40));
104+
callback.withArgs(tmpDir, "refs/pull/1/merge").resolves("b".repeat(40));
105+
callback.withArgs(sinon.match.any, "HEAD").resolves("b".repeat(40));
97106

98107
const actualRef = await gitUtils.getRef();
99108
t.deepEqual(actualRef, "refs/pull/2/merge");
109+
110+
t.true(callback.calledOnceWith(tmpDir, "refs/pull/1/merge"));
111+
t.true(callback.calledOnceWith(tmpDir, "HEAD"));
100112
});
101113
},
102114
);

0 commit comments

Comments
 (0)