mirror of
https://github.com/github/codeql-action.git
synced 2026-01-04 05:30:16 +08:00
Add extra test ensuring env var overrides cached feature flag
This commit is contained in:
@@ -340,6 +340,37 @@ test("Feature flags are saved to disk", async (t) => {
|
||||
});
|
||||
});
|
||||
|
||||
test("Environment variable can override feature flag cache", async (t) => {
|
||||
await withTmpDir(async (tmpDir) => {
|
||||
const featureEnablement = setUpFeatureFlagTests(tmpDir);
|
||||
const expectedFeatureEnablement = initializeFeatures(true);
|
||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
||||
|
||||
const cachedFeatureFlags = path.join(tmpDir, FEATURE_FLAGS_FILE_NAME);
|
||||
t.true(
|
||||
await featureEnablement.getValue(
|
||||
Feature.CliConfigFileEnabled,
|
||||
includeCodeQlIfRequired(Feature.CliConfigFileEnabled)
|
||||
),
|
||||
"Feature flag should be enabled initially"
|
||||
);
|
||||
|
||||
t.true(
|
||||
fs.existsSync(cachedFeatureFlags),
|
||||
"Feature flag cached file should exist after getting feature flags"
|
||||
);
|
||||
process.env.CODEQL_PASS_CONFIG_TO_CLI = "false";
|
||||
|
||||
t.false(
|
||||
await featureEnablement.getValue(
|
||||
Feature.CliConfigFileEnabled,
|
||||
includeCodeQlIfRequired(Feature.CliConfigFileEnabled)
|
||||
),
|
||||
"Feature flag should be disabled after setting env var"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function assertAllFeaturesUndefinedInApi(t, loggedMessages: LoggedMessage[]) {
|
||||
for (const feature of Object.keys(featureConfig)) {
|
||||
t.assert(
|
||||
|
||||
Reference in New Issue
Block a user