Use new test config for testings currently writing to the config

This commit is contained in:
Koen Vlaswinkel
2022-10-10 15:41:52 +02:00
parent b9be9cff9f
commit ae2bd81215
3 changed files with 9 additions and 13 deletions

View File

@@ -35,7 +35,6 @@ export class Setting {
}
return workspace.getConfiguration(this.parent.qualifiedName).update(this.name, value, target);
}
}
const ROOT_SETTING = new Setting('codeQL');
@@ -338,17 +337,13 @@ export function getRemoteRepositoryLists(): Record<string, string[]> | undefined
return REMOTE_REPO_LISTS.getValue<Record<string, string[]>>() || undefined;
}
export async function setRemoteRepositoryLists(lists: Record<string, string[]> | undefined) {
await REMOTE_REPO_LISTS.updateValue(lists, ConfigurationTarget.Global);
}
/**
* Path to a file that contains lists of GitHub repositories that you want to query remotely via
* Path to a file that contains lists of GitHub repositories that you want to query remotely via
* the "Run Variant Analysis" command.
* Note: This command is only available for internal users.
*
*
* This setting should be a path to a JSON file that contains a JSON object where each key is a
* user-specified name (string), and the value is an array of GitHub repositories
* user-specified name (string), and the value is an array of GitHub repositories
* (of the form `<owner>/<repo>`).
*/
const REPO_LISTS_PATH = new Setting('repositoryListsPath', REMOTE_QUERIES_SETTING);

View File

@@ -4,9 +4,10 @@ import * as fs from 'fs-extra';
import fetch from 'node-fetch';
import { fail } from 'assert';
import { commands, ConfigurationTarget, extensions, workspace } from 'vscode';
import { commands, extensions, workspace } from 'vscode';
import { CodeQLExtensionInterface } from '../../extension';
import { DatabaseManager } from '../../databases';
import { testConfig } from '../test-config';
// This file contains helpers shared between actual tests.
@@ -58,7 +59,7 @@ export default function(mocha: Mocha) {
// Set the CLI version here before activation to ensure we don't accidentally try to download a cli
(mocha.options as any).globalSetup.push(
async () => {
await workspace.getConfiguration().update('codeQL.cli.executablePath', process.env.CLI_PATH, ConfigurationTarget.Global);
await testConfig.cliExecutablePath.setInitialTestValue(process.env.CLI_PATH);
}
);

View File

@@ -10,7 +10,6 @@ import { QlPack, runRemoteQuery } from '../../../remote-queries/run-remote-query
import { Credentials } from '../../../authentication';
import { CliVersionConstraint, CodeQLCliServer } from '../../../cli';
import { CodeQLExtensionInterface } from '../../../extension';
import { setRemoteControllerRepo, setRemoteRepositoryLists } from '../../../config';
import * as config from '../../../config';
import { UserCancellationException } from '../../../commandRunner';
import * as ghApiClient from '../../../remote-queries/gh-api/gh-api-client';
@@ -24,6 +23,7 @@ import { createMockApiResponse } from '../../factories/remote-queries/gh-api/var
import { createMockExtensionContext } from '../../no-workspace';
import { VariantAnalysisManager } from '../../../remote-queries/variant-analysis-manager';
import { OutputChannelLogger } from '../../../logging';
import { testConfig } from '../../test-config';
describe('Remote queries', function() {
const baseDir = path.join(__dirname, '../../../../src/vscode-tests/cli-integration');
@@ -83,8 +83,8 @@ describe('Remote queries', function() {
getRepositoryFromNwoStub = sandbox.stub(ghApiClient, 'getRepositoryFromNwo').resolves(dummyRepository);
// always run in the vscode-codeql repo
await setRemoteControllerRepo('github/vscode-codeql');
await setRemoteRepositoryLists({ 'vscode-codeql': ['github/vscode-codeql'] });
await testConfig.remoteControllerRepo.set('github/vscode-codeql');
await testConfig.remoteRepoLists.set({ 'vscode-codeql': ['github/vscode-codeql'] });
liveResultsStub = sandbox.stub(config, 'isVariantAnalysisLiveResultsEnabled').returns(false);
});