mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-03 09:35:40 -05:00
Adds SQL Binding Create Azure Function with SQL Binding tests (#19538)
* add a couple of azure function service tests * address comments * use mock for azureFunctionExtensionAPI
This commit is contained in:
@@ -8,6 +8,7 @@ import * as TypeMoq from 'typemoq';
|
||||
import * as mssql from 'mssql';
|
||||
import * as vscodeMssql from 'vscode-mssql';
|
||||
import { RequestType } from 'vscode-languageclient';
|
||||
import { AzureFunctionsExtensionApi } from '../../../types/vscode-azurefunctions.api';
|
||||
|
||||
export interface TestUtils {
|
||||
context: vscode.ExtensionContext;
|
||||
@@ -16,6 +17,7 @@ export interface TestUtils {
|
||||
vscodeMssqlIExtension: TypeMoq.IMock<vscodeMssql.IExtension>
|
||||
dacFxMssqlService: TypeMoq.IMock<vscodeMssql.IDacFxService>;
|
||||
schemaCompareService: TypeMoq.IMock<vscodeMssql.ISchemaCompareService>;
|
||||
azureFunctionsExtensionApi: TypeMoq.IMock<AzureFunctionsExtensionApi>;
|
||||
}
|
||||
|
||||
export class MockVscodeMssqlIExtension implements vscodeMssql.IExtension {
|
||||
@@ -59,13 +61,17 @@ export class MockVscodeMssqlIExtension implements vscodeMssql.IExtension {
|
||||
}
|
||||
|
||||
export function createTestUtils(): TestUtils {
|
||||
// Need to setup then when Promise.resolving a mocked object : https://github.com/florinn/typemoq/issues/66
|
||||
const azureFunctionsExtensionApi = TypeMoq.Mock.ofType<AzureFunctionsExtensionApi>();
|
||||
azureFunctionsExtensionApi.setup((x: any) => x.then).returns(() => undefined);
|
||||
return {
|
||||
context: TypeMoq.Mock.ofType<vscode.ExtensionContext>().object,
|
||||
dacFxService: TypeMoq.Mock.ofType<mssql.IDacFxService>(),
|
||||
vscodeMssqlIExtension: TypeMoq.Mock.ofType(MockVscodeMssqlIExtension),
|
||||
dacFxMssqlService: TypeMoq.Mock.ofType<vscodeMssql.IDacFxService>(),
|
||||
schemaCompareService: TypeMoq.Mock.ofType<vscodeMssql.ISchemaCompareService>(),
|
||||
outputChannel: TypeMoq.Mock.ofType<vscode.OutputChannel>().object
|
||||
outputChannel: TypeMoq.Mock.ofType<vscode.OutputChannel>().object,
|
||||
azureFunctionsExtensionApi
|
||||
};
|
||||
}
|
||||
|
||||
@@ -107,3 +113,39 @@ export function createTestCredentials(): vscodeMssql.IConnectionInfo {
|
||||
};
|
||||
return creds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create SQL server table node used for testing
|
||||
* @param connectionInfo the connection info used for the test case
|
||||
* @returns SQL Server table node
|
||||
*/
|
||||
export function createTestTableNode(connectionInfo: vscodeMssql.IConnectionInfo): vscodeMssql.ITreeNodeInfo {
|
||||
return {
|
||||
connectionInfo: connectionInfo,
|
||||
nodeType: 'Table',
|
||||
metadata: {
|
||||
metadataType: 0,
|
||||
metadataTypeName: 'Table',
|
||||
urn: '',
|
||||
name: 'testTable',
|
||||
schema: 'testSchema',
|
||||
},
|
||||
parentNode: {
|
||||
connectionInfo: connectionInfo,
|
||||
nodeType: 'Folder',
|
||||
metadata: null!,
|
||||
parentNode: {
|
||||
connectionInfo: connectionInfo,
|
||||
nodeType: 'Database',
|
||||
metadata: {
|
||||
metadataType: 0,
|
||||
metadataTypeName: 'Database',
|
||||
urn: '',
|
||||
name: 'testDb',
|
||||
schema: null!,
|
||||
},
|
||||
parentNode: undefined! // set to undefined since we do not need further parent node
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user