This commit is contained in:
github-actions[bot] 2024-06-25 09:21:42 +00:00
parent 1895b29ac8
commit 9cf3243b0b
59 changed files with 233 additions and 248 deletions

20
lib/testing-utils.js generated
View file

@ -26,7 +26,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTestConfig = exports.mockBundleDownloadApi = exports.createFeatures = exports.mockCodeQLVersion = exports.makeVersionInfo = exports.mockLanguagesInRepo = exports.mockFeatureFlagApiEndpoint = exports.getRecordingLogger = exports.setupActionsVars = exports.setupTests = exports.LINKED_CLI_VERSION = exports.SAMPLE_DEFAULT_CLI_VERSION = exports.SAMPLE_DOTCOM_API_DETAILS = void 0;
exports.makeVersionInfo = exports.LINKED_CLI_VERSION = exports.SAMPLE_DEFAULT_CLI_VERSION = exports.SAMPLE_DOTCOM_API_DETAILS = void 0;
exports.setupTests = setupTests;
exports.setupActionsVars = setupActionsVars;
exports.getRecordingLogger = getRecordingLogger;
exports.mockFeatureFlagApiEndpoint = mockFeatureFlagApiEndpoint;
exports.mockLanguagesInRepo = mockLanguagesInRepo;
exports.mockCodeQLVersion = mockCodeQLVersion;
exports.createFeatures = createFeatures;
exports.mockBundleDownloadApi = mockBundleDownloadApi;
exports.createTestConfig = createTestConfig;
const node_util_1 = require("node:util");
const path_1 = __importDefault(require("path"));
const github = __importStar(require("@actions/github"));
@ -117,7 +126,6 @@ function setupTests(test) {
process.env = t.context.env;
});
}
exports.setupTests = setupTests;
// Sets environment variables that make using some libraries designed for
// use only on actions safe to use outside of actions.
function setupActionsVars(tempDir, toolsDir) {
@ -125,7 +133,6 @@ function setupActionsVars(tempDir, toolsDir) {
process.env["RUNNER_TOOL_CACHE"] = toolsDir;
process.env["GITHUB_WORKSPACE"] = tempDir;
}
exports.setupActionsVars = setupActionsVars;
function getRecordingLogger(messages) {
return {
debug: (message) => {
@ -153,7 +160,6 @@ function getRecordingLogger(messages) {
endGroup: () => undefined,
};
}
exports.getRecordingLogger = getRecordingLogger;
/** Mock the HTTP request to the feature flags enablement API endpoint. */
function mockFeatureFlagApiEndpoint(responseStatusCode, response) {
// Passing an auth token is required, so we just use a dummy value
@ -173,7 +179,6 @@ function mockFeatureFlagApiEndpoint(responseStatusCode, response) {
}
sinon.stub(apiClient, "getApiClient").value(() => client);
}
exports.mockFeatureFlagApiEndpoint = mockFeatureFlagApiEndpoint;
function mockLanguagesInRepo(languages) {
const mockClient = sinon.stub(apiClient, "getApiClient");
const listLanguages = sinon.stub().resolves({
@ -195,7 +200,6 @@ function mockLanguagesInRepo(languages) {
});
return listLanguages;
}
exports.mockLanguagesInRepo = mockLanguagesInRepo;
/**
* Constructs a `VersionInfo` object for testing purposes only.
*/
@ -211,7 +215,6 @@ function mockCodeQLVersion(version, features) {
},
});
}
exports.mockCodeQLVersion = mockCodeQLVersion;
/**
* Create a feature enablement instance with the specified set of enabled features.
*
@ -227,7 +230,6 @@ function createFeatures(enabledFeatures) {
},
};
}
exports.createFeatures = createFeatures;
/**
* Mocks the API for downloading the bundle tagged `tagName`.
*
@ -249,7 +251,6 @@ function mockBundleDownloadApi({ apiDetails = exports.SAMPLE_DOTCOM_API_DETAILS,
.replyWithFile(200, path_1.default.join(__dirname, `/../src/testdata/codeql-bundle${isPinned ? "-pinned" : ""}.tar.gz`));
return `${baseUrl}${relativeUrl}`;
}
exports.mockBundleDownloadApi = mockBundleDownloadApi;
function createTestConfig(overrides) {
return Object.assign({}, {
languages: [],
@ -272,5 +273,4 @@ function createTestConfig(overrides) {
trapCacheDownloadTime: 0,
}, overrides);
}
exports.createTestConfig = createTestConfig;
//# sourceMappingURL=testing-utils.js.map