mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 03:28:33 -05:00
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:
30
extensions/schema-compare/src/test/index.ts
Normal file
30
extensions/schema-compare/src/test/index.ts
Normal 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;
|
||||
77
extensions/schema-compare/src/test/schemaCompare.test.ts
Normal file
77
extensions/schema-compare/src/test/schemaCompare.test.ts
Normal 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);
|
||||
});
|
||||
});
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user