mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-13 17:22:15 -05:00
Add unit test framework for QDS Extension (#23776)
* Query store unit test infra setup * Update yarn.lock file * Update tests for utils.ts * Move test utilities interfaces and functions to its own file
This commit is contained in:
@@ -56,5 +56,10 @@
|
||||
"vscode-nls": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/azdata-test": "^3.0.1",
|
||||
"@microsoft/vscodetestcover": "^1.2.1",
|
||||
"@types/mocha": "^7.0.2",
|
||||
"should": "^13.2.1",
|
||||
"typemoq": "^2.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
11
extensions/query-store/src/test/index.ts
Normal file
11
extensions/query-store/src/test/index.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { getDefaultMochaOptions } from '@microsoft/azdata-test';
|
||||
import * as testRunner from '@microsoft/vscodetestcover';
|
||||
|
||||
testRunner.configure(getDefaultMochaOptions('Query Store Extension Tests'), { coverConfig: '../../coverConfig.json' });
|
||||
|
||||
export = testRunner;
|
||||
113
extensions/query-store/src/test/testUtils.ts
Normal file
113
extensions/query-store/src/test/testUtils.ts
Normal file
@@ -0,0 +1,113 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 interface TestContext {
|
||||
view: azdata.ModelView;
|
||||
component: azdata.Component
|
||||
}
|
||||
|
||||
export function createViewContext(): TestContext {
|
||||
let componentBase: azdata.Component = {
|
||||
id: '',
|
||||
updateProperties: () => Promise.resolve(),
|
||||
updateProperty: () => Promise.resolve(),
|
||||
updateCssStyles: undefined!,
|
||||
onValidityChanged: undefined!,
|
||||
valid: true,
|
||||
validate: undefined!,
|
||||
focus: undefined!
|
||||
};
|
||||
|
||||
const components: azdata.Component[] = [];
|
||||
let container = {
|
||||
clearItems: () => { },
|
||||
addItems: () => { },
|
||||
addItem: () => { },
|
||||
removeItem: () => true,
|
||||
insertItem: () => { },
|
||||
items: components,
|
||||
setLayout: () => { },
|
||||
setItemLayout: () => { },
|
||||
updateCssStyles: () => { }
|
||||
};
|
||||
|
||||
let flex: azdata.FlexContainer = Object.assign({}, componentBase, container, {
|
||||
});
|
||||
|
||||
let flexBuilder: azdata.FlexBuilder = Object.assign({}, {
|
||||
component: () => flex,
|
||||
withProperties: () => flexBuilder,
|
||||
withValidation: () => flexBuilder,
|
||||
withItems: () => flexBuilder,
|
||||
withLayout: () => flexBuilder,
|
||||
withProps: () => flexBuilder
|
||||
});
|
||||
|
||||
let split: azdata.SplitViewContainer = Object.assign({}, componentBase, container, {
|
||||
});
|
||||
|
||||
let splitViewBuilder: azdata.SplitViewBuilder = Object.assign({}, {
|
||||
component: () => split,
|
||||
withProperties: () => splitViewBuilder,
|
||||
withValidation: () => splitViewBuilder,
|
||||
withItems: () => splitViewBuilder,
|
||||
withLayout: () => splitViewBuilder,
|
||||
withProps: () => splitViewBuilder
|
||||
});
|
||||
|
||||
let view: azdata.ModelView = {
|
||||
onClosed: undefined!,
|
||||
connection: undefined!,
|
||||
serverInfo: undefined!,
|
||||
valid: true,
|
||||
onValidityChanged: undefined!,
|
||||
validate: undefined!,
|
||||
initializeModel: () => { return Promise.resolve(); },
|
||||
modelBuilder: {
|
||||
listView: undefined!,
|
||||
radioCardGroup: undefined!,
|
||||
navContainer: undefined!,
|
||||
divContainer: undefined!,
|
||||
flexContainer: () => flexBuilder,
|
||||
splitViewContainer: () => splitViewBuilder,
|
||||
card: undefined!,
|
||||
inputBox: () => undefined!,
|
||||
checkBox: undefined!,
|
||||
radioButton: () => undefined!,
|
||||
webView: undefined!,
|
||||
editor: undefined!,
|
||||
diffeditor: undefined!,
|
||||
text: () => undefined!,
|
||||
image: () => undefined!,
|
||||
button: () => undefined!,
|
||||
dropDown: () => undefined!,
|
||||
tree: undefined!,
|
||||
listBox: undefined!,
|
||||
table: undefined!,
|
||||
declarativeTable: () => undefined!,
|
||||
dashboardWidget: undefined!,
|
||||
dashboardWebview: undefined!,
|
||||
formContainer: () => undefined!,
|
||||
groupContainer: undefined!,
|
||||
toolbarContainer: undefined!,
|
||||
loadingComponent: () => undefined!,
|
||||
fileBrowserTree: undefined!,
|
||||
hyperlink: undefined!,
|
||||
tabbedPanel: undefined!,
|
||||
separator: undefined!,
|
||||
propertiesContainer: undefined!,
|
||||
infoBox: undefined!,
|
||||
slider: undefined!,
|
||||
executionPlan: undefined!,
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
view: view,
|
||||
component: componentBase
|
||||
};
|
||||
}
|
||||
36
extensions/query-store/src/test/utils.test.ts
Normal file
36
extensions/query-store/src/test/utils.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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';
|
||||
import * as should from 'should';
|
||||
import { createOneComponentFlexContainer, createTwoComponentFlexContainer, createVerticalSplitView } from '../common/utils';
|
||||
import { TestContext, createViewContext } from './testUtils';
|
||||
|
||||
let testContext: TestContext;
|
||||
|
||||
describe('Test to verify flex container creation util function', () => {
|
||||
beforeEach(() => {
|
||||
testContext = createViewContext();
|
||||
});
|
||||
it('Should create a component as expected with createOneComponentFlexContainer', async () => {
|
||||
let flexContainer: azdata.FlexContainer = await createOneComponentFlexContainer(testContext.view, testContext.component, 'black');
|
||||
should(flexContainer.valid).be.true();
|
||||
});
|
||||
|
||||
it('Should create a component as expected with createTwoComponentFlexContainer with row flow', () => {
|
||||
let flexContainer: azdata.FlexContainer = createTwoComponentFlexContainer(testContext.view, testContext.component, testContext.component, 'row');
|
||||
should(flexContainer.valid).be.true();
|
||||
});
|
||||
|
||||
it('Should create a component as expected with createTwoComponentFlexContainer with column flow', () => {
|
||||
let flexContainer: azdata.FlexContainer = createTwoComponentFlexContainer(testContext.view, testContext.component, testContext.component, 'column');
|
||||
should(flexContainer.valid).be.true();
|
||||
});
|
||||
|
||||
it('Should create a component as expected with createVerticalSplitView', () => {
|
||||
let splitViewContainer: azdata.SplitViewContainer = createVerticalSplitView(testContext.view, testContext.component, testContext.component, 100);
|
||||
should(splitViewContainer.valid).be.true();
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,6 +38,7 @@ if "%INTEGRATION_TEST_ELECTRON_PATH%"=="" (
|
||||
compile-extension:mssql^
|
||||
compile-extension:notebook^
|
||||
compile-extension:query-history^
|
||||
compile-extension:query-store^
|
||||
compile-extension:resource-deployment^
|
||||
compile-extension:sql-bindings^
|
||||
compile-extension:sql-database-projects
|
||||
@@ -123,6 +124,11 @@ echo *** starting query-history tests ***
|
||||
echo *******************************
|
||||
call "%INTEGRATION_TEST_ELECTRON_PATH%" --extensionDevelopmentPath=%~dp0\..\extensions\query-history --extensionTestsPath=%~dp0\..\extensions\query-history\out\test %ALL_PLATFORMS_API_TESTS_EXTRA_ARGS%
|
||||
|
||||
echo ********************************************
|
||||
echo *** starting query-store tests ***
|
||||
echo ********************************************
|
||||
call "%INTEGRATION_TEST_ELECTRON_PATH%" --extensionDevelopmentPath=%~dp0\..\extensions\query-store --extensionTestsPath=%~dp0\..\extensions\query-store\out\test %ALL_PLATFORMS_API_TESTS_EXTRA_ARGS%
|
||||
|
||||
echo ******************************************
|
||||
echo *** starting resource deployment tests ***
|
||||
echo ******************************************
|
||||
|
||||
@@ -24,6 +24,7 @@ const extensionList = [
|
||||
//'mssql',
|
||||
'notebook',
|
||||
'query-history',
|
||||
'query-store',
|
||||
'resource-deployment',
|
||||
'schema-compare',
|
||||
'sql-bindings',
|
||||
@@ -36,9 +37,9 @@ let argv = require('yargs')
|
||||
.default('extensions', extensionList)
|
||||
.strict().help().wrap(null).version(false).argv;
|
||||
|
||||
let LINUX_EXTRA_ARGS='';
|
||||
let LINUX_EXTRA_ARGS = '';
|
||||
|
||||
if(os.platform() === 'linux') {
|
||||
if (os.platform() === 'linux') {
|
||||
LINUX_EXTRA_ARGS = '--no-sandbox --disable-dev-shm-usage --use-gl=swiftshader';
|
||||
}
|
||||
|
||||
@@ -72,7 +73,7 @@ for (const ext of argv.extensions) {
|
||||
|
||||
if (os.platform() === 'darwin') {
|
||||
// passing in env on mac causes the executing the command to fail, so only pass in env for windows and linux
|
||||
console.log(execSync(command, { stdio: 'inherit'}));
|
||||
console.log(execSync(command, { stdio: 'inherit' }));
|
||||
} else {
|
||||
const env = {
|
||||
...process.env,
|
||||
@@ -80,7 +81,7 @@ for (const ext of argv.extensions) {
|
||||
ELECTRON_ENABLE_STACK_DUMPING: 1,
|
||||
ELECTRON_ENABLE_LOGGING: 1
|
||||
};
|
||||
console.log(execSync(command, { stdio: 'inherit', env: env}));
|
||||
console.log(execSync(command, { stdio: 'inherit', env: env }));
|
||||
}
|
||||
|
||||
// clean up
|
||||
|
||||
@@ -48,12 +48,13 @@ else
|
||||
compile-extension:dacpac \
|
||||
compile-extension:datavirtualization \
|
||||
compile-extension:import \
|
||||
compile-extension:schema-compare \
|
||||
compile-extension:machine-learning \
|
||||
compile-extension:mssql \
|
||||
compile-extension:notebook \
|
||||
compile-extension:query-history \
|
||||
compile-extension:query-store \
|
||||
compile-extension:resource-deployment \
|
||||
compile-extension:schema-compare \
|
||||
compile-extension:sql-bindings \
|
||||
compile-extension:sql-database-projects
|
||||
|
||||
@@ -156,6 +157,11 @@ echo *** starting query-history tests ***
|
||||
echo ******************************************
|
||||
"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_EXTRA_ARGS --extensionDevelopmentPath=$ROOT/extensions/query-history --extensionTestsPath=$ROOT/extensions/query-history/out/test $ALL_PLATFORMS_API_TESTS_EXTRA_ARGS
|
||||
|
||||
echo ********************************************
|
||||
echo *** starting query-store tests ***
|
||||
echo ********************************************
|
||||
"$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_EXTRA_ARGS --extensionDevelopmentPath=$ROOT/extensions/query-store --extensionTestsPath=$ROOT/extensions/query-store/out/test $ALL_PLATFORMS_API_TESTS_EXTRA_ARGS
|
||||
|
||||
echo ******************************************
|
||||
echo *** starting resource deployment tests ***
|
||||
echo ******************************************
|
||||
|
||||
Reference in New Issue
Block a user