test/*: use getGoConfig instead of directly calling vscode API

Change-Id: I2338412b72ad8e73d3ea37c85b21edabc28ebccd
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/283260
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
diff --git a/test/gopls/configuration.test.ts b/test/gopls/configuration.test.ts
index daccdfb..a603127 100644
--- a/test/gopls/configuration.test.ts
+++ b/test/gopls/configuration.test.ts
@@ -4,18 +4,12 @@
  *--------------------------------------------------------*/
 
 import * as assert from 'assert';
-import moment = require('moment');
-import semver = require('semver');
-import sinon = require('sinon');
-import * as vscode from 'vscode';
+import { getGoplsConfig } from '../../src/config';
 import * as lsp from '../../src/goLanguageServer';
-import { getTool, Tool } from '../../src/goTools';
 
 suite('gopls configuration tests', () => {
 	test('filterGoplsDefaultConfigValues', async () => {
-		const defaultGoplsConfig = vscode.workspace.getConfiguration('gopls');
-		const defaultGoplsAnalysesConfig = vscode.workspace.getConfiguration('gopls.analyses');
-
+		const defaultGoplsConfig = getGoplsConfig();
 		interface TestCase {
 			name: string;
 			section: string;
diff --git a/test/integration/codelens.test.ts b/test/integration/codelens.test.ts
index b5a941b..a96b957 100644
--- a/test/integration/codelens.test.ts
+++ b/test/integration/codelens.test.ts
@@ -10,6 +10,7 @@
 import path = require('path');
 import sinon = require('sinon');
 import vscode = require('vscode');
+import { getGoConfig } from '../../src/config';
 import { updateGoVarsFromConfig } from '../../src/goInstallTools';
 import { GoRunTestCodeLensProvider } from '../../src/goRunTestCodelens';
 import { subTestAtCursor } from '../../src/goTest';
@@ -55,7 +56,7 @@
 				return true;
 			},
 		});
-		goConfig = vscode.workspace.getConfiguration('go');
+		goConfig = getGoConfig();
 		const uri = vscode.Uri.file(path.join(fixturePath, 'codelens_test.go'));
 		document = await vscode.workspace.openTextDocument(uri);
 	});
diff --git a/test/integration/config.test.ts b/test/integration/config.test.ts
index a854a3c..e9fa344 100644
--- a/test/integration/config.test.ts
+++ b/test/integration/config.test.ts
@@ -76,7 +76,7 @@
 		// getter
 		Object.defineProperties(this, Object.getOwnPropertyDescriptors(workspaceSettings));
 		this.map = new Map<string, any>(Object.entries(workspaceSettings));
-		this.wrapped = vscode.workspace.getConfiguration('go');
+		this.wrapped = vscode.workspace.getConfiguration('go');  // intentionally using vscode API directly.
 	}
 
 	// tslint:disable: no-any
diff --git a/test/integration/extension.test.ts b/test/integration/extension.test.ts
index 5b75118..c33dca2 100644
--- a/test/integration/extension.test.ts
+++ b/test/integration/extension.test.ts
@@ -192,7 +192,7 @@
 	}
 
 	test('Test Definition Provider using godoc', async () => {
-		const config = Object.create(vscode.workspace.getConfiguration('go'), {
+		const config = Object.create(getGoConfig(), {
 			docsTool: { value: 'godoc' }
 		});
 		await testDefinitionProvider(config);
@@ -204,7 +204,7 @@
 			// gogetdoc is not installed, so skip the test
 			return;
 		}
-		const config = Object.create(vscode.workspace.getConfiguration('go'), {
+		const config = Object.create(getGoConfig(), {
 			docsTool: { value: 'gogetdoc' }
 		});
 		await testDefinitionProvider(config);
@@ -243,7 +243,7 @@
 				['s string']
 			]
 		];
-		const config = Object.create(vscode.workspace.getConfiguration('go'), {
+		const config = Object.create(getGoConfig(), {
 			docsTool: { value: 'godoc' }
 		});
 		await testSignatureHelpProvider(config, testCases);
@@ -286,7 +286,7 @@
 				['s string']
 			]
 		];
-		const config = Object.create(vscode.workspace.getConfiguration('go'), {
+		const config = Object.create(getGoConfig(), {
 			docsTool: { value: 'gogetdoc' }
 		});
 		await testSignatureHelpProvider(config, testCases);
@@ -313,7 +313,7 @@
 				`This is an unexported function so couldn't get this comment on hover :( Not\nanymore!!\n`
 			]
 		];
-		const config = Object.create(vscode.workspace.getConfiguration('go'), {
+		const config = Object.create(getGoConfig(), {
 			docsTool: { value: 'godoc' }
 		});
 		await testHoverProvider(config, testCases);
@@ -358,7 +358,7 @@
 				'IPv4Mask returns the IP mask (in 4-byte form) of the\nIPv4 mask a.b.c.d.\n'
 			]
 		];
-		const config = Object.create(vscode.workspace.getConfiguration('go'), {
+		const config = Object.create(getGoConfig(), {
 			docsTool: { value: 'gogetdoc' }
 		});
 		await testHoverProvider(config, testCases);
@@ -370,7 +370,7 @@
 		sinon.spy(util, 'runTool');
 		sinon.spy(processutil, 'killProcessTree');
 
-		const config = Object.create(vscode.workspace.getConfiguration('go'), {
+		const config = Object.create(getGoConfig(), {
 			vetOnSave: { value: 'package' },
 			vetFlags: { value: ['-all'] },
 			buildOnSave: { value: 'package' },
@@ -394,7 +394,7 @@
 		// the adjustment is made consistently across multiple open text documents.
 		const file1 = await vscode.workspace.openTextDocument(vscode.Uri.file(path.join(fixturePath, 'linterTest', 'linter_1.go')));
 		const file2 = await vscode.workspace.openTextDocument(vscode.Uri.file(path.join(fixturePath, 'linterTest', 'linter_2.go')));
-		const warnings = await goLint(file2.uri, Object.create(vscode.workspace.getConfiguration('go'), {
+		const warnings = await goLint(file2.uri, Object.create(getGoConfig(), {
 			lintTool: { value: 'golint' },
 			lintFlags: { value: [] }
 		}), 'package');
@@ -412,7 +412,7 @@
 	});
 
 	test('Error checking', async () => {
-		const config = Object.create(vscode.workspace.getConfiguration('go'), {
+		const config = Object.create(getGoConfig(), {
 			vetOnSave: { value: 'package' },
 			vetFlags: { value: ['-all'] },
 			lintOnSave: { value: 'package' },
@@ -575,7 +575,7 @@
 	});
 
 	test('Test Env Variables are passed to Tests', async () => {
-		const config = Object.create(vscode.workspace.getConfiguration('go'), {
+		const config = Object.create(getGoConfig(), {
 			testEnvVars: { value: { dummyEnvVar: 'dummyEnvValue', dummyNonString: 1 } }
 		});
 		const uri = vscode.Uri.file(path.join(fixturePath, 'baseTest', 'sample_test.go'));
@@ -772,28 +772,28 @@
 
 	test('Workspace Symbols', () => {
 		const workspacePath = path.join(fixturePath, 'vendoring');
-		const configWithoutIgnoringFolders = Object.create(vscode.workspace.getConfiguration('go'), {
+		const configWithoutIgnoringFolders = Object.create(getGoConfig(), {
 			gotoSymbol: {
 				value: {
 					ignoreFolders: []
 				}
 			}
 		});
-		const configWithIgnoringFolders = Object.create(vscode.workspace.getConfiguration('go'), {
+		const configWithIgnoringFolders = Object.create(getGoConfig(), {
 			gotoSymbol: {
 				value: {
 					ignoreFolders: ['vendor']
 				}
 			}
 		});
-		const configWithIncludeGoroot = Object.create(vscode.workspace.getConfiguration('go'), {
+		const configWithIncludeGoroot = Object.create(getGoConfig(), {
 			gotoSymbol: {
 				value: {
 					includeGoroot: true
 				}
 			}
 		});
-		const configWithoutIncludeGoroot = Object.create(vscode.workspace.getConfiguration('go'), {
+		const configWithoutIncludeGoroot = Object.create(getGoConfig(), {
 			gotoSymbol: {
 				value: {
 					includeGoroot: false
@@ -887,7 +887,7 @@
 	test('Test Completion Snippets For Functions', async () => {
 		const provider = new GoCompletionItemProvider();
 		const uri = vscode.Uri.file(path.join(fixturePath, 'completions', 'snippets.go'));
-		const baseConfig = vscode.workspace.getConfiguration('go');
+		const baseConfig = getGoConfig();
 		const textDocument = await vscode.workspace.openTextDocument(uri);
 		const editor = await vscode.window.showTextDocument(textDocument);
 
@@ -1081,7 +1081,7 @@
 	test('Test No Completion Snippets For Functions', async () => {
 		const provider = new GoCompletionItemProvider();
 		const uri = vscode.Uri.file(path.join(fixturePath, 'completions', 'nosnippets.go'));
-		const baseConfig = vscode.workspace.getConfiguration('go');
+		const baseConfig = getGoConfig();
 		const textDocument = await vscode.workspace.openTextDocument(uri);
 		const editor = await vscode.window.showTextDocument(textDocument);
 
@@ -1146,7 +1146,7 @@
 	});
 
 	test('Test Completion on unimported packages', async () => {
-		const config = Object.create(vscode.workspace.getConfiguration('go'), {
+		const config = Object.create(getGoConfig(), {
 			autocompleteUnimportedPackages: { value: true }
 		});
 		const provider = new GoCompletionItemProvider();
@@ -1177,7 +1177,7 @@
 	});
 
 	test('Test Completion on unimported packages (multiple)', async () => {
-		const config = Object.create(vscode.workspace.getConfiguration('go'), {
+		const config = Object.create(getGoConfig(), {
 			gocodeFlags: { value: ['-builtin'] }
 		});
 		const provider = new GoCompletionItemProvider();
@@ -1293,7 +1293,7 @@
 				}
 				fmt.Print("Go!")
 			}`;
-		const goConfig = Object.create(vscode.workspace.getConfiguration('go'), {
+		const goConfig = Object.create(getGoConfig(), {
 			playground: { value: { run: true, openbrowser: false, share: false } }
 		});
 
@@ -1325,7 +1325,7 @@
 				}
 				fmt.Print("Go!")
 			}`;
-		const goConfig = Object.create(vscode.workspace.getConfiguration('go'), {
+		const goConfig = Object.create(getGoConfig(), {
 			playground: { value: { run: true, openbrowser: false, share: true } }
 		});
 
@@ -1355,7 +1355,7 @@
 			func fantasy() {
 				fmt.Print("not a main package, sorry")
 			}`;
-		const goConfig = Object.create(vscode.workspace.getConfiguration('go'), {
+		const goConfig = Object.create(getGoConfig(), {
 			playground: { value: { run: true, openbrowser: false, share: false } }
 		});
 
@@ -1417,7 +1417,7 @@
 	});
 
 	test('Test Tags checking', async () => {
-		const config1 = Object.create(vscode.workspace.getConfiguration('go'), {
+		const config1 = Object.create(getGoConfig(), {
 			vetOnSave: { value: 'off' },
 			lintOnSave: { value: 'off' },
 			buildOnSave: { value: 'package' },
@@ -1425,21 +1425,21 @@
 			buildTags: { value: 'randomtag' }
 		});
 
-		const config2 = Object.create(vscode.workspace.getConfiguration('go'), {
+		const config2 = Object.create(getGoConfig(), {
 			vetOnSave: { value: 'off' },
 			lintOnSave: { value: 'off' },
 			buildOnSave: { value: 'package' },
 			testTags: { value: 'randomtag' }
 		});
 
-		const config3 = Object.create(vscode.workspace.getConfiguration('go'), {
+		const config3 = Object.create(getGoConfig(), {
 			vetOnSave: { value: 'off' },
 			lintOnSave: { value: 'off' },
 			buildOnSave: { value: 'package' },
 			testTags: { value: 'randomtag othertag' }
 		});
 
-		const config4 = Object.create(vscode.workspace.getConfiguration('go'), {
+		const config4 = Object.create(getGoConfig(), {
 			vetOnSave: { value: 'off' },
 			lintOnSave: { value: 'off' },
 			buildOnSave: { value: 'package' },
diff --git a/test/integration/install.test.ts b/test/integration/install.test.ts
index d73350d..879aa19 100644
--- a/test/integration/install.test.ts
+++ b/test/integration/install.test.ts
@@ -13,6 +13,7 @@
 import url = require('url');
 import util = require('util');
 import vscode = require('vscode');
+import { getGoConfig } from '../../src/config';
 import { toolInstallationEnvironment } from '../../src/goEnv';
 import { installTools } from '../../src/goInstallTools';
 import { allToolsInformation, getConfiguredTools, getTool, getToolAtVersion } from '../../src/goTools';
@@ -70,7 +71,7 @@
 		let configStub: sinon.SinonStub;
 		if (withLocalProxy) {
 			proxyDir = buildFakeProxy([].concat(...testCases));
-			const goConfig = Object.create(vscode.workspace.getConfiguration('go'), {
+			const goConfig = Object.create(getGoConfig(), {
 				toolsEnvVars: {
 					value: {
 						GOPROXY: url.pathToFileURL(proxyDir),
diff --git a/test/integration/test.test.ts b/test/integration/test.test.ts
index 670a8bc..27ef442 100644
--- a/test/integration/test.test.ts
+++ b/test/integration/test.test.ts
@@ -135,7 +135,7 @@
 		input: { isMod: boolean, includeSubDirectories: boolean, testFlags?: string[], applyCodeCoverage?: boolean },
 		wantFiles: string[]) {
 
-		const config = Object.create(vscode.workspace.getConfiguration('go'));
+		const config = Object.create(getGoConfig());
 		const outputChannel = new FakeOutputChannel();
 
 		const testConfig = {