mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Schema Compare tests for utils (#10759)
* Added a few tests for utils file under Schema Compare * Addressed comment- moved mock test data to a common location
This commit is contained in:
55
extensions/schema-compare/src/test/utils.test.ts
Normal file
55
extensions/schema-compare/src/test/utils.test.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as should from 'should';
|
||||
import * as mssql from '../../../mssql';
|
||||
import {getEndpointName, verifyConnectionAndGetOwnerUri } from '../utils';
|
||||
import {mockDacpacEndpoint, mockDatabaseEndpoint, mockFilePath, mockConnectionInfo} from './testUtils';
|
||||
|
||||
describe('utils: Tests to verify getEndpointName', function (): void {
|
||||
it('Should generate correct endpoint information', async () => {
|
||||
let endpointInfo: mssql.SchemaCompareEndpointInfo;
|
||||
|
||||
should(getEndpointName(endpointInfo)).equal(' ');
|
||||
should(getEndpointName(mockDacpacEndpoint)).equal(mockFilePath);
|
||||
should(getEndpointName(mockDatabaseEndpoint)).equal(' ');
|
||||
});
|
||||
|
||||
it('Should get endpoint information from ConnectionInfo', async () => {
|
||||
let testDatabaseEndpoint: mssql.SchemaCompareEndpointInfo = mockDatabaseEndpoint;
|
||||
testDatabaseEndpoint.connectionDetails = mockConnectionInfo;
|
||||
|
||||
should(getEndpointName(testDatabaseEndpoint)).equal('My Server.My Database');
|
||||
});
|
||||
|
||||
it('Should get correct endpoint information from SchemaCompareEndpointInfo', async () => {
|
||||
let dbName = 'My Database';
|
||||
let serverName = 'My Server';
|
||||
let testDatabaseEndpoint: mssql.SchemaCompareEndpointInfo = {...mockDatabaseEndpoint};
|
||||
testDatabaseEndpoint.databaseName = dbName;
|
||||
testDatabaseEndpoint.serverName = serverName;
|
||||
|
||||
should(getEndpointName(testDatabaseEndpoint)).equal('My Server.My Database');
|
||||
});
|
||||
});
|
||||
|
||||
describe('utils: Tests to verify verifyConnectionAndGetOwnerUri', function (): void {
|
||||
it('Should return undefined for endpoint as dacpac', async function (): Promise<void> {
|
||||
let ownerUri = undefined;
|
||||
ownerUri = await verifyConnectionAndGetOwnerUri(mockDacpacEndpoint, 'test');
|
||||
|
||||
should(ownerUri).equal(undefined);
|
||||
});
|
||||
|
||||
it('Should return undefined for endpoint as database and no ConnectionInfo', async function (): Promise<void> {
|
||||
let ownerUri = undefined;
|
||||
let testDatabaseEndpoint: mssql.SchemaCompareEndpointInfo = {...mockDatabaseEndpoint};
|
||||
testDatabaseEndpoint.connectionDetails = undefined;
|
||||
|
||||
ownerUri = await verifyConnectionAndGetOwnerUri(testDatabaseEndpoint, 'test');
|
||||
|
||||
should(ownerUri).equal(undefined);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user