mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Adding unit tests for schema compare service (#13642)
This commit is contained in:
@@ -8,7 +8,6 @@ import * as vscode from 'vscode';
|
||||
import * as mssql from '../../mssql';
|
||||
import * as os from 'os';
|
||||
import * as loc from './localizedConstants';
|
||||
import { ApiWrapper } from './common/apiWrapper';
|
||||
import { promises as fs } from 'fs';
|
||||
|
||||
export interface IPackageInfo {
|
||||
@@ -32,7 +31,7 @@ export function getPackageInfo(packageJson: any): IPackageInfo {
|
||||
* @param msg The error message to map
|
||||
*/
|
||||
export function getTelemetryErrorType(msg: string): string {
|
||||
if (msg.indexOf('Object reference not set to an instance of an object') !== -1) {
|
||||
if (msg && msg.indexOf('Object reference not set to an instance of an object') !== -1) {
|
||||
return 'ObjectReferenceNotSet';
|
||||
}
|
||||
else {
|
||||
@@ -85,18 +84,18 @@ function connectionInfoToConnectionProfile(details: azdata.ConnectionInfo): azda
|
||||
};
|
||||
}
|
||||
|
||||
export async function verifyConnectionAndGetOwnerUri(endpoint: mssql.SchemaCompareEndpointInfo, caller: string, apiWrapper: ApiWrapper): Promise<string | undefined> {
|
||||
export async function verifyConnectionAndGetOwnerUri(endpoint: mssql.SchemaCompareEndpointInfo, caller: string): Promise<string | undefined> {
|
||||
let ownerUri = undefined;
|
||||
|
||||
if (endpoint.endpointType === mssql.SchemaCompareEndpointType.Database && endpoint.connectionDetails) {
|
||||
let connectionProfile = await connectionInfoToConnectionProfile(endpoint.connectionDetails);
|
||||
let connection = await apiWrapper.connect(connectionProfile, false, false);
|
||||
let connection = await azdata.connection.connect(connectionProfile, false, false);
|
||||
|
||||
if (connection) {
|
||||
ownerUri = await apiWrapper.getUriForConnection(connection.connectionId);
|
||||
ownerUri = await azdata.connection.getUriForConnection(connection.connectionId);
|
||||
|
||||
if (!ownerUri) {
|
||||
let connectionList = await apiWrapper.getConnections(true);
|
||||
let connectionList = await azdata.connection.getConnections(true);
|
||||
|
||||
let userConnection;
|
||||
userConnection = connectionList.find(connection =>
|
||||
@@ -109,18 +108,18 @@ export async function verifyConnectionAndGetOwnerUri(endpoint: mssql.SchemaCompa
|
||||
if (userConnection === undefined) {
|
||||
const getConnectionString = loc.getConnectionString(caller);
|
||||
// need only yes button - since the modal dialog has a default cancel
|
||||
let result = await apiWrapper.showWarningMessage(getConnectionString, { modal: true }, loc.YesButtonText);
|
||||
let result = await vscode.window.showWarningMessage(getConnectionString, { modal: true }, loc.YesButtonText);
|
||||
if (result === loc.YesButtonText) {
|
||||
userConnection = await apiWrapper.openConnectionDialog(undefined, connectionProfile);
|
||||
userConnection = await azdata.connection.openConnectionDialog(undefined, connectionProfile);
|
||||
}
|
||||
}
|
||||
|
||||
if (userConnection !== undefined) {
|
||||
ownerUri = await apiWrapper.getUriForConnection(userConnection.connectionId);
|
||||
ownerUri = await azdata.connection.getUriForConnection(userConnection.connectionId);
|
||||
}
|
||||
}
|
||||
if (!ownerUri && connection.errorMessage) {
|
||||
apiWrapper.showErrorMessage(connection.errorMessage);
|
||||
vscode.window.showErrorMessage(connection.errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user