mirror of
https://github.com/github/codeql-action.git
synced 2025-12-28 02:00:12 +08:00
Add unit test for YAML support in CODEQL_ACTION_EXTRA_OPTIONS
This commit is contained in:
12
lib/util.test.js
generated
12
lib/util.test.js
generated
@@ -31,6 +31,7 @@ const os = __importStar(require("os"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const ava_1 = __importDefault(require("ava"));
|
||||
const yaml = __importStar(require("js-yaml"));
|
||||
const sinon = __importStar(require("sinon"));
|
||||
const api = __importStar(require("./api-client"));
|
||||
const environment_1 = require("./environment");
|
||||
@@ -136,16 +137,23 @@ for (const { input, totalMemoryMb, platform, expectedMemoryValue, reservedPercen
|
||||
t.deepEqual(util.getExtraOptionsEnvParam(), options);
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions;
|
||||
});
|
||||
(0, ava_1.default)("getExtraOptionsEnvParam() succeeds on valid options", (t) => {
|
||||
(0, ava_1.default)("getExtraOptionsEnvParam() succeeds on valid JSON options", (t) => {
|
||||
const origExtraOptions = process.env.CODEQL_ACTION_EXTRA_OPTIONS;
|
||||
const options = { database: { init: ["--debug"] } };
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = JSON.stringify(options);
|
||||
t.deepEqual(util.getExtraOptionsEnvParam(), options);
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions;
|
||||
});
|
||||
(0, ava_1.default)("getExtraOptionsEnvParam() succeeds on valid YAML options", (t) => {
|
||||
const origExtraOptions = process.env.CODEQL_ACTION_EXTRA_OPTIONS;
|
||||
const options = { database: { init: ["--debug"] } };
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = yaml.dump(options);
|
||||
t.deepEqual(util.getExtraOptionsEnvParam(), { ...options });
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions;
|
||||
});
|
||||
(0, ava_1.default)("getExtraOptionsEnvParam() fails on invalid JSON", (t) => {
|
||||
const origExtraOptions = process.env.CODEQL_ACTION_EXTRA_OPTIONS;
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = "{{invalid-json}}";
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = "{{invalid-json}";
|
||||
t.throws(util.getExtraOptionsEnvParam);
|
||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions;
|
||||
});
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user