Skip to content

Commit c2215db

Browse files
committed
Update git-utils tests
1 parent 5769ffc commit c2215db

1 file changed

Lines changed: 26 additions & 12 deletions

File tree

‎src/git-utils.test.ts‎

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ test.serial(
3434
});
3535

3636
const callback = sinon.stub(gitUtils, "getCommitOid");
37-
callback.withArgs(sinon.match.string, "HEAD").resolves(currentSha);
37+
callback
38+
.withArgs(sinon.match.any, sinon.match.string, "HEAD")
39+
.resolves(currentSha);
3840

3941
const actualRef = await gitUtils.getRef(env, tmpDir);
4042
t.deepEqual(actualRef, expectedRef);
4143

4244
t.is(callback.callCount, 1);
43-
t.true(callback.calledOnceWith(tmpDir, "HEAD"));
45+
t.true(callback.calledOnceWith(env, tmpDir, "HEAD"));
4446
});
4547
},
4648
);
@@ -60,16 +62,22 @@ test.serial(
6062

6163
const callback = sinon.stub(gitUtils, "getCommitOid");
6264
callback
63-
.withArgs(sinon.match.string, "refs/remotes/pull/1/merge")
65+
.withArgs(
66+
sinon.match.any,
67+
sinon.match.string,
68+
"refs/remotes/pull/1/merge",
69+
)
70+
.resolves(sha);
71+
callback
72+
.withArgs(sinon.match.any, sinon.match.string, "HEAD")
6473
.resolves(sha);
65-
callback.withArgs(sinon.match.any, "HEAD").resolves(sha);
6674

6775
const actualRef = await gitUtils.getRef(env, tmpDir);
6876
t.deepEqual(actualRef, expectedRef);
6977

7078
t.is(callback.callCount, 2);
71-
t.true(callback.calledWith(tmpDir, "HEAD"));
72-
t.true(callback.calledWith(tmpDir, "refs/remotes/pull/1/merge"));
79+
t.true(callback.calledWith(env, tmpDir, "HEAD"));
80+
t.true(callback.calledWith(env, tmpDir, "refs/remotes/pull/1/merge"));
7381
});
7482
},
7583
);
@@ -87,17 +95,19 @@ test.serial(
8795

8896
const callback = sinon.stub(gitUtils, "getCommitOid");
8997
callback
90-
.withArgs(tmpDir, "refs/remotes/pull/1/merge")
98+
.withArgs(sinon.match.any, tmpDir, "refs/remotes/pull/1/merge")
9199
.resolves("a".repeat(40));
92-
callback.withArgs(tmpDir, "HEAD").resolves("b".repeat(40));
100+
callback
101+
.withArgs(sinon.match.any, tmpDir, "HEAD")
102+
.resolves("b".repeat(40));
93103
callback.throws(new Error("Unexpected getCommitOid call in test."));
94104

95105
const actualRef = await gitUtils.getRef(env, tmpDir);
96106
t.deepEqual(actualRef, "refs/pull/1/head");
97107

98108
t.is(callback.callCount, 2);
99-
t.true(callback.calledWith(tmpDir, "refs/remotes/pull/1/merge"));
100-
t.true(callback.calledWith(tmpDir, "HEAD"));
109+
t.true(callback.calledWith(env, tmpDir, "refs/remotes/pull/1/merge"));
110+
t.true(callback.calledWith(env, tmpDir, "HEAD"));
101111
});
102112
},
103113
);
@@ -122,8 +132,12 @@ test.serial(
122132
});
123133

124134
const callback = sinon.stub(gitUtils, "getCommitOid");
125-
callback.withArgs(tmpDir, "refs/pull/1/merge").resolves("b".repeat(40));
126-
callback.withArgs(sinon.match.any, "HEAD").resolves("b".repeat(40));
135+
callback
136+
.withArgs(sinon.match.any, tmpDir, "refs/pull/1/merge")
137+
.resolves("b".repeat(40));
138+
callback
139+
.withArgs(sinon.match.any, sinon.match.string, "HEAD")
140+
.resolves("b".repeat(40));
127141

128142
const actualRef = await gitUtils.getRef(env, tmpDir);
129143
t.deepEqual(actualRef, "refs/pull/2/merge");

0 commit comments

Comments
 (0)