Code refactoring for extension testing (#10529)

* Setting up tests on import extension

* -Added API wrappers for all the azdata and vscode APIs to make them easily mockable
-Added some unit tests for the import extension
-Some code logic separations

* -added code report for the import extension in ci

* Did some more code refractoring

* -Added json report generation

* updated vscodetestcoverage to latest version in import extension.

* -remove duplicate codecoverageConfig.json
This commit is contained in:
Aasim Khan
2020-06-16 13:24:48 -07:00
committed by GitHub
parent 94bc0d9559
commit f725ee96b9
22 changed files with 1356 additions and 231 deletions

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as constants from '../constants';
import * as constants from '../common/constants';
import * as azdata from 'azdata';
import ControllerBase from './controllerBase';
import * as vscode from 'vscode';
@@ -11,14 +11,22 @@ import { FlatFileWizard } from '../wizard/flatFileWizard';
import { ServiceClient } from '../services/serviceClient';
import { ApiType, managerInstance } from '../services/serviceApiManager';
import { FlatFileProvider } from '../services/contracts';
import { ApiWrapper } from '../common/apiWrapper';
/**
* The main controller class that initializes the extension
*/
export default class MainController extends ControllerBase {
private _outputChannel: vscode.OutputChannel;
private _apiWrapper: ApiWrapper;
public constructor(context: vscode.ExtensionContext) {
public constructor(
context: vscode.ExtensionContext,
apiWrapper: ApiWrapper
) {
super(context);
this._apiWrapper = apiWrapper;
this._outputChannel = this._apiWrapper.createOutputChannel(constants.serviceName);
}
/**
*/
@@ -27,18 +35,17 @@ export default class MainController extends ControllerBase {
public async activate(): Promise<boolean> {
return new Promise<boolean>(async (resolve) => {
const outputChannel = vscode.window.createOutputChannel(constants.serviceName);
managerInstance.onRegisteredApi<FlatFileProvider>(ApiType.FlatFileProvider)(provider => {
this.initializeFlatFileProvider(provider);
resolve(true);
});
await new ServiceClient(outputChannel).startService(this._context);
await new ServiceClient(this._outputChannel, this._apiWrapper).startService(this._context);
});
}
private initializeFlatFileProvider(provider: FlatFileProvider) {
azdata.tasks.registerTask('flatFileImport.start', (profile: azdata.IConnectionProfile, ...args: any[]) => new FlatFileWizard(provider).start(profile, args));
this._apiWrapper.registerTask(constants.flatFileImportStartCommand, (profile: azdata.IConnectionProfile, ...args: any[]) => new FlatFileWizard(provider, this._apiWrapper).start(profile, args));
}
}