Engineering work to make our repos more consistent πŸ‘·πŸ»β€β™‚οΈ (#1387)

This commit is contained in:
Eric Jizba 2020-03-31 10:37:05 -07:00 ΠΊΠΎΠΌΠΌΠΈΡ‚ ΠΏΡ€ΠΎΠΈΠ·Π²Ρ‘Π» GitHub
Π ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ f2a4db33fe
ΠšΠΎΠΌΠΌΠΈΡ‚ f2a9fe129f
НС Π½Π°ΠΉΠ΄Π΅Π½ ΠΊΠ»ΡŽΡ‡, ΡΠΎΠΎΡ‚Π²Π΅Ρ‚ΡΡ‚Π²ΡƒΡŽΡ‰ΠΈΠΉ Π΄Π°Π½Π½ΠΎΠΉ подписи
Π˜Π΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€ ΠΊΠ»ΡŽΡ‡Π° GPG: 4AEE18F83AFDEB23
24 ΠΈΠ·ΠΌΠ΅Π½Ρ‘Π½Π½Ρ‹Ρ… Ρ„Π°ΠΉΠ»ΠΎΠ²: 2284 Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠΉ ΠΈ 2884 ΡƒΠ΄Π°Π»Π΅Π½ΠΈΠΉ

1
.gitignore поставляСмый
ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -258,6 +258,7 @@ paket-files/
# Artifacts from running vscode extension tests
.vscode-test
test-results.xml
testWorkspace
# Artifacts from ANTLR4 extension
grammar/.antlr

77
.vscode/launch.json поставляСмый
ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -10,18 +10,33 @@
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"stopOnEntry": false,
"sourceMaps": true,
// outFiles is used for locating generated JavaScript files, see https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_source-maps
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm: compile",
"preLaunchTask": "${defaultBuildTask}",
"env": {
"DEBUGTELEMETRY": "1",
"DEBUGTELEMETRY": "v",
"NODE_DEBUG": ""
}
},
{
"name": "Launch Extension (webpack)",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "npm: webpack",
"env": {
"DEBUGTELEMETRY": "v",
"NODE_DEBUG": "",
"DEBUG_WEBPACK": "1"
}
},
{
"name": "Launch Tests",
"type": "extensionHost",
@ -29,64 +44,42 @@
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test"
"--extensionTestsPath=${workspaceFolder}/out/test/index",
"${workspaceFolder}/test/test.code-workspace"
],
"stopOnEntry": false,
"sourceMaps": true,
// outFiles is used for locating generated JavaScript files, see https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_source-maps
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm: compile",
"preLaunchTask": "${defaultBuildTask}",
"env": {
"MOCHA_fgrep": "", // Search string of tests to run (empty for all)
"MOCHA_grep": "", // RegExp of tests to run (empty for all)
"MOCHA_enableTimeouts": "0", // Disable time-outs
"DEBUGTELEMETRY": "1",
"NODE_DEBUG": ""
"MOCHA_timeout": "0", // Disable time-outs
"DEBUGTELEMETRY": "v",
"NODE_DEBUG": "",
"ENABLE_LONG_RUNNING_TESTS": ""
}
},
{
"name": "Launch Extension (Webpack)",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"stopOnEntry": false,
"sourceMaps": true,
// outFiles is used for locating generated JavaScript files, see https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_source-maps
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "npm: webpack",
"env": {
"DEBUGTELEMETRY": "1",
"NODE_DEBUG": ""
}
},
{
"name": "Launch Tests (Webpack)",
"name": "Launch Tests (webpack)",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/dist/test"
"--extensionTestsPath=${workspaceFolder}/dist/test/index",
"${workspaceFolder}/test/test.code-workspace"
],
"stopOnEntry": false,
"sourceMaps": true,
// outFiles is used for locating generated JavaScript files, see https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_source-maps
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "npm: webpack",
"env": {
"MOCHA_grep": "", // RegExp of tests to run (empty for all)
"MOCHA_enableTimeouts": "0", // Disable time-outs
"DEBUGTELEMETRY": "1",
"NODE_DEBUG": ""
"MOCHA_timeout": "0", // Disable time-outs
"DEBUGTELEMETRY": "v",
"NODE_DEBUG": "",
"DEBUG_WEBPACK": "1",
"ENABLE_LONG_RUNNING_TESTS": ""
}
},
{

21
.vscode/settings.json поставляСмый
ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -1,27 +1,26 @@
{
"editor.formatOnSave": true,
"files.exclude": {
".vscode-test": true
"editor.codeActionsOnSave": {
"source.fixAll.tslint": true,
"source.organizeImports": true
},
"files.trimTrailingWhitespace": true,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"editor.formatOnSave": true,
"editor.insertSpaces": true,
"editor.tabSize": 4,
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"search.exclude": {
"out": true,
"**/node_modules": true,
".vscode-test": true
},
"tslint.ignoreDefinitionFiles": true,
"typescript.preferences.importModuleSpecifier": "relative",
"typescript.tsdk": "node_modules/typescript/lib",
"antlr4.generation": {
// Settings for "ANTLR4 grammar syntax support" extension
"mode": "internal",
"listeners": true,
"visitors": false
},
"editor.codeActionsOnSave": {
"source.fixAll.tslint": true,
},
"tslint.ignoreDefinitionFiles": true,
"typescript.preferences.importModuleSpecifier": "relative"
}
}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -25,3 +25,4 @@ build
*.ts
*.zip
*.mongo
testWorkspace/**

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -5,7 +5,6 @@
// tslint:disable:no-implicit-dependencies (this allows the use of dev dependencies)
import * as cp from 'child_process';
import * as fse from 'fs-extra';
import * as gulp from 'gulp';
import * as path from 'path';
@ -20,14 +19,6 @@ async function prepareForWebpack(): Promise<void> {
await fse.writeFile(mainJsPath, contents);
}
function test(): cp.ChildProcess {
const env = process.env;
env.DEBUGTELEMETRY = '1';
env.CODE_TESTS_PATH = path.join(__dirname, 'dist/test');
return cp.spawn('node', ['./node_modules/vscode/bin/test'], { stdio: 'inherit', env });
}
exports['webpack-dev'] = gulp.series(prepareForWebpack, () => gulp_webpack('development'));
exports['webpack-prod'] = gulp.series(prepareForWebpack, () => gulp_webpack('production'));
exports.test = gulp.series(gulp_installAzureAccount, test);
exports.preTest = gulp_installAzureAccount;

4784
package-lock.json сгСнСрированный

Π Π°Π·Π½ΠΈΡ†Π° ΠΌΠ΅ΠΆΠ΄Ρƒ Ρ„Π°ΠΉΠ»Π°ΠΌΠΈ Π½Π΅ ΠΏΠΎΠΊΠ°Π·Π°Π½Π° ΠΈΠ·-Π·Π° своСго большого Ρ€Π°Π·ΠΌΠ΅Ρ€Π° Π—Π°Π³Ρ€ΡƒΠ·ΠΈΡ‚ΡŒ Ρ€Π°Π·Π½ΠΈΡ†Ρƒ

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -817,14 +817,13 @@
},
"scripts": {
"vscode:prepublish": "npm run webpack-prod",
"build": "tsc -p ./",
"compile": "tsc -watch -p ./",
"build": "tsc",
"compile": "tsc -watch",
"package": "vsce package",
"lint": "tslint --project tsconfig.json -t verbose",
"lint-fix": "tslint --project tsconfig.json -t verbose --fix",
"postinstall": "node ./node_modules/vscode/bin/install",
"pretest": "npm run webpack-prod",
"test": "gulp test",
"pretest": "npm run webpack-prod && gulp preTest",
"test": "node ./out/test/runTest.js",
"update-grammar": "antlr4ts -visitor ./grammar/mongo.g4 -o ./src/mongo/grammar",
"webpack": "npm run build && gulp webpack-dev",
"webpack-prod": "npm run build && gulp webpack-prod",
@ -833,16 +832,18 @@
},
"devDependencies": {
"@types/documentdb": "^1.10.2",
"@types/fs-extra": "^4.0.3",
"@types/fs-extra": "^8.1.0",
"@types/keytar": "4.0.1",
"@types/mocha": "^5.2.5",
"@types/mocha": "^7.0.2",
"@types/mongodb": "^3.3.2",
"@types/node": "^10.0.0",
"@types/vscode": "1.31.0",
"antlr4ts-cli": "^0.4.0-alpha.4",
"azure-arm-resource": "^3.0.0-preview",
"copy-webpack-plugin": "^4.5.4",
"copy-webpack-plugin": "^5.1.1",
"glob": "^7.1.6",
"gulp": "^4.0.0",
"mocha": "^5.2.0",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"mocha-multi-reporters": "^1.1.7",
"string-replace-webpack-plugin": "^0.1.3",
@ -851,8 +852,8 @@
"tslint-microsoft-contrib": "5.0.1",
"typescript": "^3.8.3",
"vsce": "^1.37.5",
"vscode": "^1.1.18",
"vscode-azureextensiondev": "^0.2.3",
"vscode-azureextensiondev": "^0.3.1",
"vscode-test": "^1.3.0",
"webpack": "4.28.1",
"webpack-cli": "^3.1.2"
},
@ -862,7 +863,7 @@
"azure-arm-postgresql": "^4.3.0",
"bson": "^1.1.3",
"documentdb": "^1.14.2",
"fs-extra": "^4.0.2",
"fs-extra": "^8.0.0",
"mongodb": "^3.3.2",
"mongodb-extended-json": "^1.10.0",
"ms-rest": "^2.2.1",
@ -870,7 +871,7 @@
"pg": "^7.18.1",
"pg-structure": "^5.10.7",
"underscore": "^1.8.3",
"vscode-azureextensionui": "^0.29.9",
"vscode-azureextensionui": "^0.29.12",
"vscode-json-languageservice": "^3.0.8",
"vscode-languageclient": "^4.4.0",
"vscode-languageserver": "^4.4.0",

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -18,6 +18,7 @@ import { IMongoDocument, MongoDocumentTreeItem } from './MongoDocumentTreeItem';
const EJSON = require("mongodb-extended-json");
type MongoFunction = (...args: ({} | {}[] | undefined)[]) => Thenable<string>;
type MongoDocument = { _id: string };
class FunctionDescriptor {
public constructor(public mongoFunction: MongoFunction, public text: string, public minShellArgs: number, public maxShellArgs: number, public maxHandledArgs: number) {
}
@ -103,7 +104,7 @@ export class MongoCollectionTreeItem extends AzureParentTreeItem<IMongoTreeRoot>
public async createChildImpl(context: ICreateChildImplContext): Promise<MongoDocumentTreeItem> {
context.showCreatingTreeItem("");
const result: InsertOneWriteOpResult = await this.collection.insertOne({});
const result: InsertOneWriteOpResult<MongoDocument> = await this.collection.insertOne({});
const newDocument: IMongoDocument = nonNullValue(await this.collection.findOne({ _id: result.insertedId }), 'newDocument');
return new MongoDocumentTreeItem(this, newDocument);
}
@ -189,7 +190,7 @@ export class MongoCollectionTreeItem extends AzureParentTreeItem<IMongoTreeRoot>
// tslint:disable-next-line:no-any
private async insertOne(document: Object, options?: any): Promise<string> {
const insertOneResult: InsertOneWriteOpResult = await this.collection.insertOne(document, { w: options && options.writeConcern });
const insertOneResult: InsertOneWriteOpResult<MongoDocument> = await this.collection.insertOne(document, { w: options && options.writeConcern });
return this.stringify(insertOneResult);
}
@ -206,7 +207,7 @@ export class MongoCollectionTreeItem extends AzureParentTreeItem<IMongoTreeRoot>
}
}
const insertManyResult: InsertWriteOpResult = await this.collection.insertMany(documents, insertManyOptions);
const insertManyResult: InsertWriteOpResult<MongoDocument> = await this.collection.insertMany(documents, insertManyOptions);
return this.stringify(insertManyResult);
}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -6,7 +6,7 @@
import * as assert from 'assert';
import { AttachedAccountsTreeItem, MONGO_CONNECTION_EXPECTED } from '../extension.bundle';
function assertConnectionValid(connectionString: string, expected: string | undefined) {
function assertConnectionValid(connectionString: string, expected: string | undefined): void {
const actual = AttachedAccountsTreeItem.validateMongoConnectionString(connectionString);
assert.equal(actual, expected);
}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -4,10 +4,9 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { parseDocDBConnectionString } from '../extension.bundle';
import { emulatorPassword } from '../extension.bundle';
import { emulatorPassword, parseDocDBConnectionString } from '../extension.bundle';
function testConnectionString(connectionString: string, expectedEndpoint: string, expectedKey: string, expectedDatabaseName: string | undefined) {
function testConnectionString(connectionString: string, expectedEndpoint: string, expectedKey: string, expectedDatabaseName: string | undefined): void {
const parsedCS = parseDocDBConnectionString(connectionString);
assert.equal(parsedCS.documentEndpoint, expectedEndpoint);
assert.equal(parsedCS.masterKey, expectedKey);

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -3,7 +3,6 @@
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IHookCallbackContext } from 'mocha';
import * as vscode from 'vscode';
import { TestOutputChannel, TestUserInput } from 'vscode-azureextensiondev';
import { ext } from '../extension.bundle';
@ -13,7 +12,7 @@ export let longRunningTestsEnabled: boolean = !/^(false|0)?$/i.test(process.env.
export const testUserInput: TestUserInput = new TestUserInput(vscode);
// Runs before all tests
suiteSetup(async function (this: IHookCallbackContext): Promise<void> {
suiteSetup(async function (this: Mocha.Context): Promise<void> {
this.timeout(2 * 60 * 1000);
await vscode.commands.executeCommand('cosmosDB.refresh'); // activate the extension before tests begin
ext.outputChannel = new TestOutputChannel();

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -3,68 +3,55 @@
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as glob from 'glob';
import * as Mocha from 'mocha';
import * as path from 'path';
//
// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
//
// This file is providing the test runner to use when running extension tests.
// By default the test runner in use is Mocha based.
//
// You can provide your own test runner if you want to override it by exporting
// a function run(testRoot: string, clb: (error:Error) => void) that the extension
// host can call to run the tests. The test runner is expected to use console.log
// to report the results back to the caller. When the tests are finished, return
// a possible error to the callback or null if none.
// tslint:disable-next-line:no-require-imports no-var-requires
const testRunner = require('vscode/lib/testrunner');
const options: { [key: string]: string | boolean | number | object } = {
ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.)
useColors: true // colored output from test results
};
// You can directly control Mocha options using environment variables beginning with MOCHA_.
// For example:
// {
// "name": "Launch Tests",
// "type": "extensionHost",
// "request": "launch",
// ...
// "env": {
// "MOCHA_enableTimeouts": "0",
// "MOCHA_grep": "tests-to-run"
// }
//
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for all available options
// Defaults
options.reporter = 'mocha-multi-reporters';
options.reporterOptions = {
reporterEnabled: "spec, mocha-junit-reporter",
mochaJunitReporterReporterOptions: {
mochaFile: path.join(__dirname, '..', '..', 'test-results.xml')
}
};
const environmentVariables = <{ [key: string]: string }>process.env;
for (const envVar of Object.keys(environmentVariables)) {
const match = envVar.match(/^mocha_(.+)/i);
if (match) {
const [, option] = match;
let value: string | number = environmentVariables[envVar];
if (typeof value === 'string' && !isNaN(parseInt(value, undefined))) {
value = parseInt(value, undefined);
// tslint:disable-next-line: export-name
export async function run(): Promise<void> {
const options: Mocha.MochaOptions = {
ui: 'tdd',
color: true,
reporter: 'mocha-multi-reporters',
reporterOptions: {
reporterEnabled: 'spec, mocha-junit-reporter',
mochaJunitReporterReporterOptions: {
mochaFile: path.resolve(__dirname, '..', '..', 'test-results.xml')
}
}
};
options[option] = value;
addEnvVarsToMochaOptions(options);
console.log(`Mocha options: ${JSON.stringify(options, undefined, 2)}`);
const mocha = new Mocha(options);
const files: string[] = await new Promise((resolve, reject) => {
glob('**/**.test.js', { cwd: __dirname }, (err, result) => {
err ? reject(err) : resolve(result);
});
});
files.forEach(f => mocha.addFile(path.resolve(__dirname, f)));
const failures = await new Promise<number>(resolve => mocha.run(resolve));
if (failures > 0) {
throw new Error(`${failures} tests failed.`);
}
}
console.warn(`Mocha options: ${JSON.stringify(options, null, 2)}`);
// tslint:disable-next-line: no-unsafe-any
testRunner.configure(options);
module.exports = testRunner;
function addEnvVarsToMochaOptions(options: Mocha.MochaOptions): void {
for (const envVar of Object.keys(process.env)) {
const match: RegExpMatchArray | null = envVar.match(/^mocha_(.+)/i);
if (match) {
const [, option] = match;
// tslint:disable-next-line:strict-boolean-expressions
let value: string | number = process.env[envVar] || '';
if (typeof value === 'string' && !isNaN(parseInt(value))) {
value = parseInt(value);
}
// tslint:disable-next-line: no-any
(<any>options)[option] = value;
}
}
}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -6,12 +6,12 @@
import * as assert from 'assert';
import { addDatabaseToAccountConnectionString, emulatorPassword, getDatabaseNameFromConnectionString } from '../extension.bundle';
function testDatabaseToAccountConnectionString(connectionString: string, databaseName: string, expectedConnectionString: string | undefined) {
function testDatabaseToAccountConnectionString(connectionString: string, databaseName: string, expectedConnectionString: string | undefined): void {
const databaseConnectionString = addDatabaseToAccountConnectionString(connectionString, databaseName);
assert.equal(databaseConnectionString, expectedConnectionString);
}
function testDatabaseNameFromConectionString(connectionString: string, expectedDatabaseName: string | undefined) {
function testDatabaseNameFromConectionString(connectionString: string, expectedDatabaseName: string | undefined): void {
const databaseName = getDatabaseNameFromConnectionString(connectionString);
assert.equal(databaseName, expectedDatabaseName);
}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -23,8 +23,8 @@ function expectSingleCommand(text: string): MongoCommand {
function testParse(
text: string,
expectedCommand: { collection: string | undefined, name: string | undefined, args: any[] | undefined, firstErrorText?: string } | undefined
) {
function testCore(coreText) {
): void {
function testCore(coreText: string): void {
const command = expectSingleCommand(coreText);
if (expectedCommand) {
assert.ok(command, "Expected a command, but found none");
@ -71,7 +71,7 @@ function testParse(
testCore(spaceText);
}
function wrapInQuotes(word: string, numQuotes: number) { //0 to do nothing, 1 for single quotes, 2 for double quotes
function wrapInQuotes(word: string, numQuotes: number): string { //0 to do nothing, 1 for single quotes, 2 for double quotes
let result: string;
if (numQuotes === 1) {
result = `'${word}'`;

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -28,7 +28,7 @@ if (!isWindows) {
testsSupported = false;
}
suite("MongoShell", function (this: Mocha.Suite) {
suite("MongoShell", function (this: Mocha.Suite): void {
function testIfSupported(title: string, fn?: Mocha.Func | Mocha.AsyncFunc): void {
if (testsSupported) {
test(title, fn);
@ -70,7 +70,7 @@ suite("MongoShell", function (this: Mocha.Suite) {
public clear(): void { }
public show(preserveFocus?: boolean): void;
public show(column?: vscode.ViewColumn, preserveFocus?: boolean): void;
public show(_column?: any, _preserveFocus?: any) { }
public show(_column?: any, _preserveFocus?: any): void { }
public hide(): void { }
public dispose(): void { }
}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -5,18 +5,17 @@
import * as assert from 'assert';
import { CosmosDBManagementModels } from 'azure-arm-cosmosdb';
import { IHookCallbackContext, ISuiteCallbackContext } from 'mocha';
import * as vscode from 'vscode';
import { randomUtils } from '../../extension.bundle';
import { longRunningTestsEnabled, testUserInput } from '../global.test';
import { client, resourceGroupsToDelete } from './global.resource.test';
suite('Graph action', async function (this: ISuiteCallbackContext): Promise<void> {
suite('Graph action', async function (this: Mocha.Suite): Promise<void> {
this.timeout(20 * 60 * 1000);
let resourceGroupName: string;
let accountName: string;
suiteSetup(async function (this: IHookCallbackContext): Promise<void> {
suiteSetup(async function (this: Mocha.Context): Promise<void> {
if (!longRunningTestsEnabled) {
this.skip();
}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -5,7 +5,6 @@
import * as assert from 'assert';
import { CosmosDBManagementModels } from 'azure-arm-cosmosdb';
import { IHookCallbackContext, ISuiteCallbackContext } from 'mocha';
import { Collection, MongoClient } from 'mongodb';
import * as vscode from 'vscode';
import { appendExtensionUserAgent, connectToMongoClient, DialogResponses, IDatabaseInfo, randomUtils } from '../../extension.bundle';
@ -13,7 +12,7 @@ import { longRunningTestsEnabled, testUserInput } from '../global.test';
import { getConnectionString } from './getConnectionString';
import { client, resourceGroupsToDelete, testAccount } from './global.resource.test';
suite('MongoDB action', async function (this: ISuiteCallbackContext): Promise<void> {
suite('MongoDB action', async function (this: Mocha.Suite): Promise<void> {
this.timeout(20 * 60 * 1000);
let resourceGroupName: string;
let accountName: string;
@ -21,7 +20,7 @@ suite('MongoDB action', async function (this: ISuiteCallbackContext): Promise<vo
let databaseName2: string;
let collectionName1: string;
suiteSetup(async function (this: IHookCallbackContext): Promise<void> {
suiteSetup(async function (this: Mocha.Context): Promise<void> {
if (!longRunningTestsEnabled) {
this.skip();
}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -6,21 +6,20 @@
import * as assert from 'assert';
import { CosmosDBManagementModels } from 'azure-arm-cosmosdb';
import { CollectionMeta, DatabaseMeta, DocumentClient, QueryError } from 'documentdb';
import { IHookCallbackContext, ISuiteCallbackContext } from 'mocha';
import * as vscode from 'vscode';
import { DialogResponses, getDocumentClient, ParsedDocDBConnectionString, parseDocDBConnectionString, randomUtils } from '../../extension.bundle';
import { longRunningTestsEnabled, testUserInput } from '../global.test';
import { getConnectionString } from './getConnectionString';
import { client, resourceGroupsToDelete, testAccount } from './global.resource.test';
suite('SQL action', async function (this: ISuiteCallbackContext): Promise<void> {
suite('SQL action', async function (this: Mocha.Suite): Promise<void> {
this.timeout(20 * 60 * 1000);
let resourceGroupName: string;
let accountName: string;
let databaseName: string;
let collectionId2: string;
suiteSetup(async function (this: IHookCallbackContext): Promise<void> {
suiteSetup(async function (this: Mocha.Context): Promise<void> {
if (!longRunningTestsEnabled) {
this.skip();
}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -5,7 +5,6 @@
import { CosmosDBManagementClient } from 'azure-arm-cosmosdb';
import { ResourceManagementClient } from 'azure-arm-resource';
import { IHookCallbackContext } from 'mocha';
import * as vscode from 'vscode';
import { TestAzureAccount } from 'vscode-azureextensiondev';
import { AzExtTreeDataProvider, AzureAccountTreeItemWithAttached, createAzureClient, ext } from '../../extension.bundle';
@ -15,26 +14,23 @@ export let testAccount: TestAzureAccount;
export let client: CosmosDBManagementClient;
export const resourceGroupsToDelete: string[] = [];
suiteSetup(async function (this: IHookCallbackContext): Promise<void> {
if (!longRunningTestsEnabled) {
this.skip();
suiteSetup(async function (this: Mocha.Context): Promise<void> {
if (longRunningTestsEnabled) {
this.timeout(2 * 60 * 1000);
testAccount = new TestAzureAccount(vscode);
await testAccount.signIn();
ext.azureAccountTreeItem = new AzureAccountTreeItemWithAttached(testAccount);
ext.tree = new AzExtTreeDataProvider(ext.azureAccountTreeItem, 'cosmosDB.loadMore');
client = createAzureClient(testAccount.getSubscriptionContext(), CosmosDBManagementClient);
}
this.timeout(2 * 60 * 1000);
testAccount = new TestAzureAccount(vscode);
await testAccount.signIn();
ext.azureAccountTreeItem = new AzureAccountTreeItemWithAttached(testAccount);
ext.tree = new AzExtTreeDataProvider(ext.azureAccountTreeItem, 'cosmosDB.loadMore');
client = createAzureClient(testAccount.getSubscriptionContext(), CosmosDBManagementClient);
});
suiteTeardown(async function (this: IHookCallbackContext): Promise<void> {
if (!longRunningTestsEnabled) {
this.skip();
suiteTeardown(async function (this: Mocha.Context): Promise<void> {
if (longRunningTestsEnabled) {
this.timeout(10 * 60 * 1000);
await deleteResourceGroups();
ext.azureAccountTreeItem.dispose();
}
this.timeout(10 * 60 * 1000);
await deleteResourceGroups();
ext.azureAccountTreeItem.dispose();
});
async function deleteResourceGroups(): Promise<void> {

29
test/runTest.ts Normal file
ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -0,0 +1,29 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
import { runTests } from 'vscode-test';
async function main(): Promise<void> {
try {
const repoRoot: string = path.resolve(__dirname, '..', '..');
await runTests({
extensionDevelopmentPath: repoRoot,
launchArgs: [
path.resolve(repoRoot, 'test', 'test.code-workspace')
],
extensionTestsPath: path.resolve(repoRoot, 'dist', 'test', 'index'),
extensionTestsEnv: {
DEBUGTELEMETRY: 'v'
}
});
} catch (err) {
console.error('Failed to run tests');
process.exit(1);
}
}
// tslint:disable-next-line: no-floating-promises
main();

8
test/test.code-workspace Normal file
ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -0,0 +1,8 @@
{
"folders": [
{
"path": "../testWorkspace"
}
],
"settings": {}
}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -1,17 +1,28 @@
{
"extends": "../tslint.json",
"rules": {
"align": false,
"max-func-body-length": false,
"no-any": false,
"no-console": false,
"no-empty": false,
"no-implicit-dependencies": [
true,
"dev"
"dev",
[
"vscode"
]
],
"typedef": false,
"no-unexternalized-strings": false,
"no-multiline-string": false,
"no-any": false,
"no-empty": false,
"max-func-body-length": false,
"no-non-null-assertion": false
"no-non-null-assertion": false,
"no-unexternalized-strings": false,
"no-unsafe-any": false,
"typedef": [
true,
"call-signature",
"parameter",
"property-declaration",
"member-variable-declaration"
]
}
}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -19,7 +19,7 @@
"alwaysStrict": true,
"paths": {
"*": [
"node_modules/vscode/*",
"node_modules/@types/*",
"*"
]
}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -98,7 +98,8 @@
},
"linterOptions": {
"exclude": [
"src/mongo/grammar/**" // generated files
"src/mongo/grammar/**", // generated files
"**/*.d.ts"
]
}
}