Convert deprecation warning to error

This commit is contained in:
Angela P Wen 2025-01-07 13:59:42 -08:00
parent a06dbc607d
commit 04b5afaa72
9 changed files with 44 additions and 39 deletions

16
lib/util.test.js generated
View file

@ -350,21 +350,21 @@ const CHECK_ACTION_VERSION_TESTS = [
["3.2.1", { type: util.GitHubVariant.GHES, version: "3.11" }, false],
["3.2.1", { type: util.GitHubVariant.GHES, version: "3.12" }, false],
];
for (const [version, githubVersion, shouldReportWarning,] of CHECK_ACTION_VERSION_TESTS) {
const reportWarningDescription = shouldReportWarning
? "reports warning"
: "doesn't report warning";
for (const [version, githubVersion, shouldReportError,] of CHECK_ACTION_VERSION_TESTS) {
const reportErrorDescription = shouldReportError
? "reports error"
: "doesn't report error";
const versionsDescription = `CodeQL Action version ${version} and GitHub version ${formatGitHubVersion(githubVersion)}`;
(0, ava_1.default)(`checkActionVersion ${reportWarningDescription} for ${versionsDescription}`, async (t) => {
const warningSpy = sinon.spy(core, "warning");
(0, ava_1.default)(`checkActionVersion ${reportErrorDescription} for ${versionsDescription}`, async (t) => {
const warningSpy = sinon.spy(core, "error");
const versionStub = sinon
.stub(api, "getGitHubVersion")
.resolves(githubVersion);
// call checkActionVersion twice and assert below that warning is reported only once
util.checkActionVersion(version, await api.getGitHubVersion());
util.checkActionVersion(version, await api.getGitHubVersion());
if (shouldReportWarning) {
t.true(warningSpy.calledOnceWithExactly(sinon.match("CodeQL Action v2 will be deprecated")));
if (shouldReportError) {
t.true(warningSpy.calledOnceWithExactly(sinon.match("CodeQL Action major versions v1 and v2 have been deprecated.")));
}
else {
t.false(warningSpy.called);