mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Tests for Schema Compare utils file (#10822)
* Introduced ApiWrapper for testability * Added tests for coverage of utils.ts * Addressed comments
This commit is contained in:
@@ -5,9 +5,11 @@
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as mssql from '../../../mssql';
|
||||
import should = require('should');
|
||||
import { AssertionError } from 'assert';
|
||||
|
||||
// Mock test data
|
||||
export const mockConnectionProfile: azdata.IConnectionProfile = {
|
||||
export const mockIConnectionProfile: azdata.IConnectionProfile = {
|
||||
connectionName: 'My Connection',
|
||||
serverName: 'My Server',
|
||||
databaseName: 'My Database',
|
||||
@@ -23,6 +25,35 @@ export const mockConnectionProfile: azdata.IConnectionProfile = {
|
||||
options: null
|
||||
};
|
||||
|
||||
export const mockConnectionProfile: azdata.connection.ConnectionProfile = {
|
||||
providerId: 'My Provider',
|
||||
connectionId: 'My Id',
|
||||
connectionName: 'My Connection',
|
||||
serverName: 'My Server',
|
||||
databaseName: 'My Database',
|
||||
userName: 'My User',
|
||||
password: 'My Pwd',
|
||||
authenticationType: 'SqlLogin',
|
||||
savePassword: false,
|
||||
groupFullName: 'My groupName',
|
||||
groupId: 'My GroupId',
|
||||
saveProfile: true,
|
||||
options: {
|
||||
server: 'My Server',
|
||||
database: 'My Database',
|
||||
user: 'My User',
|
||||
password: 'My Pwd',
|
||||
authenticationType: 'SqlLogin'
|
||||
}
|
||||
};
|
||||
|
||||
export const mockConnectionResult: azdata.ConnectionResult = {
|
||||
connected: false,
|
||||
connectionId: undefined,
|
||||
errorMessage: 'Login failed for user \'sa\'',
|
||||
errorCode: 18456
|
||||
};
|
||||
|
||||
export const mockConnectionInfo = {
|
||||
options: {},
|
||||
serverName: 'My Server',
|
||||
@@ -53,3 +84,18 @@ export const mockDatabaseEndpoint: mssql.SchemaCompareEndpointInfo = {
|
||||
packageFilePath: '',
|
||||
connectionDetails: undefined
|
||||
};
|
||||
|
||||
export async function shouldThrowSpecificError(block: Function, expectedMessage: string, details?: string) {
|
||||
let succeeded = false;
|
||||
try {
|
||||
await block();
|
||||
succeeded = true;
|
||||
}
|
||||
catch (err) {
|
||||
should(err.message).equal(expectedMessage);
|
||||
}
|
||||
|
||||
if (succeeded) {
|
||||
throw new AssertionError({ message: `Operation succeeded, but expected failure with exception: "${expectedMessage}".${details ? ' ' + details : ''}` });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user