mirror of
https://github.com/github/codeql-action.git
synced 2025-12-22 15:20:19 +08:00
build: refresh js files
This commit is contained in:
43
lib/testing-utils.js
generated
43
lib/testing-utils.js
generated
@@ -41,9 +41,11 @@ exports.setupTests = setupTests;
|
||||
exports.setupActionsVars = setupActionsVars;
|
||||
exports.getRecordingLogger = getRecordingLogger;
|
||||
exports.mockFeatureFlagApiEndpoint = mockFeatureFlagApiEndpoint;
|
||||
exports.stubFeatureFlagApiEndpoint = stubFeatureFlagApiEndpoint;
|
||||
exports.mockLanguagesInRepo = mockLanguagesInRepo;
|
||||
exports.mockCodeQLVersion = mockCodeQLVersion;
|
||||
exports.createFeatures = createFeatures;
|
||||
exports.initializeFeatures = initializeFeatures;
|
||||
exports.mockBundleDownloadApi = mockBundleDownloadApi;
|
||||
exports.createTestConfig = createTestConfig;
|
||||
const node_util_1 = require("node:util");
|
||||
@@ -54,6 +56,7 @@ const sinon = __importStar(require("sinon"));
|
||||
const apiClient = __importStar(require("./api-client"));
|
||||
const codeql = __importStar(require("./codeql"));
|
||||
const defaults = __importStar(require("./defaults.json"));
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const util_1 = require("./util");
|
||||
exports.SAMPLE_DOTCOM_API_DETAILS = {
|
||||
auth: "token",
|
||||
@@ -172,21 +175,32 @@ function getRecordingLogger(messages) {
|
||||
}
|
||||
/** Mock the HTTP request to the feature flags enablement API endpoint. */
|
||||
function mockFeatureFlagApiEndpoint(responseStatusCode, response) {
|
||||
stubFeatureFlagApiEndpoint(() => ({
|
||||
status: responseStatusCode,
|
||||
messageIfError: "some error message",
|
||||
data: response,
|
||||
}));
|
||||
}
|
||||
/** Stub the HTTP request to the feature flags enablement API endpoint. */
|
||||
function stubFeatureFlagApiEndpoint(responseFunction) {
|
||||
// Passing an auth token is required, so we just use a dummy value
|
||||
const client = github.getOctokit("123");
|
||||
const requestSpy = sinon.stub(client, "request");
|
||||
const optInSpy = requestSpy.withArgs("GET /repos/:owner/:repo/code-scanning/codeql-action/features");
|
||||
if (responseStatusCode < 300) {
|
||||
optInSpy.resolves({
|
||||
status: responseStatusCode,
|
||||
data: response,
|
||||
headers: {},
|
||||
url: "GET /repos/:owner/:repo/code-scanning/codeql-action/features",
|
||||
});
|
||||
}
|
||||
else {
|
||||
optInSpy.throws(new util_1.HTTPError("some error message", responseStatusCode));
|
||||
}
|
||||
optInSpy.callsFake((_route, params) => {
|
||||
const response = responseFunction(params);
|
||||
if (response.status < 300) {
|
||||
return Promise.resolve({
|
||||
status: response.status,
|
||||
data: response.data,
|
||||
headers: {},
|
||||
url: "GET /repos/:owner/:repo/code-scanning/codeql-action/features",
|
||||
});
|
||||
}
|
||||
else {
|
||||
throw new util_1.HTTPError(response.messageIfError || "default stub error message", response.status);
|
||||
}
|
||||
});
|
||||
sinon.stub(apiClient, "getApiClient").value(() => client);
|
||||
}
|
||||
function mockLanguagesInRepo(languages) {
|
||||
@@ -240,6 +254,12 @@ function createFeatures(enabledFeatures) {
|
||||
},
|
||||
};
|
||||
}
|
||||
function initializeFeatures(initialValue) {
|
||||
return Object.keys(feature_flags_1.featureConfig).reduce((features, key) => {
|
||||
features[key] = initialValue;
|
||||
return features;
|
||||
}, {});
|
||||
}
|
||||
/**
|
||||
* Mocks the API for downloading the bundle tagged `tagName`.
|
||||
*
|
||||
@@ -282,6 +302,7 @@ function createTestConfig(overrides) {
|
||||
augmentationProperties: {
|
||||
packsInputCombines: false,
|
||||
queriesInputCombines: false,
|
||||
extraQueryExclusions: [],
|
||||
},
|
||||
trapCaches: {},
|
||||
trapCacheDownloadTime: 0,
|
||||
|
||||
Reference in New Issue
Block a user