Move makeVersionOutput to testing-utils.js

This commit is contained in:
Michael B. Gale 2023-10-04 15:45:42 +01:00
parent a402be8739
commit e827ad5b71
No known key found for this signature in database
GPG key ID: FF5E2765BD00628F
18 changed files with 110 additions and 114 deletions

19
lib/testing-utils.js generated
View file

@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.mockBundleDownloadApi = exports.createFeatures = exports.mockCodeQLVersion = exports.mockLanguagesInRepo = exports.mockFeatureFlagApiEndpoint = exports.getRecordingLogger = exports.setupActionsVars = exports.setupTests = exports.SAMPLE_DEFAULT_CLI_VERSION = exports.SAMPLE_DOTCOM_API_DETAILS = void 0;
exports.mockBundleDownloadApi = exports.createFeatures = exports.mockCodeQLVersion = exports.makeVersionOutput = exports.mockLanguagesInRepo = exports.mockFeatureFlagApiEndpoint = exports.getRecordingLogger = exports.setupActionsVars = exports.setupTests = exports.SAMPLE_DEFAULT_CLI_VERSION = exports.SAMPLE_DOTCOM_API_DETAILS = void 0;
const node_util_1 = require("node:util");
const path_1 = __importDefault(require("path"));
const github = __importStar(require("@actions/github"));
@ -187,10 +187,25 @@ function mockLanguagesInRepo(languages) {
return listLanguages;
}
exports.mockLanguagesInRepo = mockLanguagesInRepo;
/**
* Constructs a `VersionOutput` object for testing purposes only.
*/
const makeVersionOutput = (version) => ({
productName: "CodeQL",
vendor: "GitHub",
sha: "",
branches: [],
copyright: "",
unpackedLocation: "",
configFileLocation: "",
configFileFound: false,
version,
});
exports.makeVersionOutput = makeVersionOutput;
function mockCodeQLVersion(version) {
return {
async getVersion() {
return CodeQL.makeVersionOutput(version);
return (0, exports.makeVersionOutput)(version);
},
};
}