Adds check on inputs and compiled files

This commit is contained in:
Alex Croteau 2022-01-25 22:37:02 -05:00
parent 5916f9896d
commit 1eaaf07b91
10 changed files with 111 additions and 15 deletions

View file

@ -79,8 +79,41 @@ test("getRef() returns ref provided as an input and ignores current HEAD", async
callback.withArgs("HEAD").resolves("b".repeat(40));
const actualRef = await actionsutil.getRef();
t.deepEqual(actualRef, "refs/pull/2/head");
t.deepEqual(actualRef, "refs/pull/2/merge");
callback.restore();
getAdditionalInputStub.restore();
});
test("getRef() throws an error if only `ref` is provided as an input", async (t) => {
const getAdditionalInputStub = sinon.stub(actionsutil, "getOptionalInput");
getAdditionalInputStub.withArgs("ref").resolves("refs/pull/1/merge");
await t.throwsAsync(
async () => {
await actionsutil.getRef();
},
{
instanceOf: Error,
message: "Both 'ref' and 'sha' are required if one of them is provided.",
}
);
getAdditionalInputStub.restore();
});
test("getRef() throws an error if only `sha` is provided as an input", async (t) => {
const getAdditionalInputStub = sinon.stub(actionsutil, "getOptionalInput");
getAdditionalInputStub.withArgs("sha").resolves("a".repeat(40));
await t.throwsAsync(
async () => {
await actionsutil.getRef();
},
{
instanceOf: Error,
message: "Both 'ref' and 'sha' are required if one of them is provided.",
}
);
getAdditionalInputStub.restore();
});
test("computeAutomationID()", async (t) => {