Schema Compare tests addition (#5136)

* initial tests for schema compare

* Adding schema compare integration test

* Adding code to fix some build issues

* DB compare test

* Adding some CR comments

* db creation and deletion as per CR comments
This commit is contained in:
udeeshagautam
2019-05-21 11:17:52 -07:00
committed by GitHub
parent c84367e2ee
commit 3fc2ad5bc9
12 changed files with 652 additions and 4 deletions

View File

@@ -0,0 +1,30 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const path = require('path');
const testRunner = require('vscode/lib/testrunner');
const suite = 'Schema Compare Tests';
const options: any = {
ui: 'bdd',
useColors: true,
timeout: 60000
};
if (process.env.BUILD_ARTIFACTSTAGINGDIRECTORY) {
options.reporter = 'mocha-multi-reporters';
options.reporterOptions = {
reporterEnabled: 'spec, mocha-junit-reporter',
mochaJunitReporterReporterOptions: {
testsuitesTitle: `${suite} ${process.platform}`,
mochaFile: path.join(process.env.BUILD_ARTIFACTSTAGINGDIRECTORY, `test-results/${process.platform}-${suite.toLowerCase().replace(/[^\w]/g, '-')}-results.xml`)
}
};
}
testRunner.configure(options);
export = testRunner;

View File

@@ -0,0 +1,77 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as should from 'should';
import * as TypeMoq from 'typemoq';
import * as vscode from 'vscode';
import * as azdata from 'azdata';
import 'mocha';
import { SchemaCompareDialog } from './../dialogs/schemaCompareDialog';
import { SchemaCompareResult } from './../schemaCompareResult';
import { SchemaCompareTestService } from './testSchemaCompareService';
// Mock test data
const mockConnectionProfile: azdata.IConnectionProfile = {
connectionName: 'My Connection',
serverName: 'My Server',
databaseName: 'My Server',
userName: 'My User',
password: 'My Pwd',
authenticationType: 'SqlLogin',
savePassword: false,
groupFullName: 'My groupName',
groupId: 'My GroupId',
providerName: 'My Server',
saveProfile: true,
id: 'My Id',
options: null
};
const mocksource: string = 'source.dacpac';
const mocktarget: string = 'target.dacpac';
const mockSourceEndpoint: azdata.SchemaCompareEndpointInfo = {
endpointType: azdata.SchemaCompareEndpointType.Dacpac,
serverName: '',
databaseName: '',
ownerUri: '',
packageFilePath: mocksource
};
const mockTargetEndpoint: azdata.SchemaCompareEndpointInfo = {
endpointType: azdata.SchemaCompareEndpointType.Dacpac,
serverName: '',
databaseName: '',
ownerUri: '',
packageFilePath: mocktarget
};
describe('SchemaCompareDialog.openDialog', function(): void {
it('Should be correct when created.', function(): void {
let dialog = new SchemaCompareDialog();
dialog.openDialog(mockConnectionProfile);
should(dialog.dialog.title).equal('Schema Compare');
should(dialog.dialog.okButton.label).equal('Compare');
should(dialog.dialog.okButton.enabled).equal(true);
});
});
describe('SchemaCompareResult.start', function(): void {
it('Should be correct when created.', async function(): Promise<void> {
let sc = new SchemaCompareTestService();
azdata.dataprotocol.registerSchemaCompareServicesProvider(sc);
let result = new SchemaCompareResult(mocksource, mocktarget, mockSourceEndpoint, mockTargetEndpoint);
let promise = new Promise(resolve => setTimeout(resolve, 3000)); // to ensure comparision result view is initialized
await promise;
await result.start();
should(result.getComparisionResult().success).equal(true);
should(result.getComparisionResult().operationId).equal(sc.testOperationId);
});
});

View File

@@ -0,0 +1,45 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as azdata from 'azdata';
export class SchemaCompareTestService implements azdata.SchemaCompareServicesProvider {
testOperationId: string = 'Test Operation Id';
schemaComparePublishChanges(operationId: string, targetServerName: string, targetDatabaseName: string, taskExecutionMode: azdata.TaskExecutionMode): Thenable<azdata.ResultStatus> {
throw new Error('Method not implemented.');
}
schemaCompareGetDefaultOptions(): Thenable<azdata.SchemaCompareOptionsResult> {
throw new Error('Method not implemented.');
}
schemaCompareIncludeExcludeNode(operationId: string, diffEntry: azdata.DiffEntry, IncludeRequest: boolean, taskExecutionMode: azdata.TaskExecutionMode): Thenable<azdata.ResultStatus> {
throw new Error('Method not implemented.');
}
schemaCompare(sourceEndpointInfo: azdata.SchemaCompareEndpointInfo, targetEndpointInfo: azdata.SchemaCompareEndpointInfo, taskExecutionMode: azdata.TaskExecutionMode): Thenable<azdata.SchemaCompareResult> {
let result: azdata.SchemaCompareResult = {
operationId: this.testOperationId,
areEqual: true,
differences: [],
success: true,
errorMessage: ''
};
return Promise.resolve(result);
}
schemaCompareGenerateScript(operationId: string, targetServerName: string, targetDatabaseName: string, taskExecutionMode: azdata.TaskExecutionMode): Thenable<azdata.DacFxResult> {
return undefined;
}
handle?: number;
readonly providerId: string = 'MSSQL';
registerOnUpdated(handler: () => any): void {
}
}