Skip to content
Merged
1 change: 1 addition & 0 deletions extension.bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// At runtime the tests live in dist/tests and will therefore pick up the main webpack bundle at dist/extension.bundle.js.
export * from '@microsoft/vscode-azext-utils';
// Export activate/deactivate for main.js
export * from './src/commands/createManagedEnvironment/createManagedEnvironment';
export * from './src/commands/deployWorkspaceProject/deployWorkspaceProject';
export * from './src/commands/deployWorkspaceProject/getDeployWorkspaceProjectResults';
export * from './src/commands/deployWorkspaceProject/internal/DeployWorkspaceProjectInternalContext';
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@
"devDependencies": {
"@azure/ms-rest-azure-env": "^2.0.0",
"@microsoft/eslint-config-azuretools": "^0.2.2",
"@microsoft/vscode-azext-dev": "^2.0.4",
"@microsoft/vscode-azext-dev": "^2.0.5",
"@types/deep-eql": "^4.0.0",
"@types/fs-extra": "^8.1.1",
"@types/gulp": "^4.0.6",
Expand Down Expand Up @@ -799,7 +799,7 @@
"@azure/storage-blob": "^12.4.1",
"@microsoft/vscode-azext-azureutils": "^3.1.1",
"@microsoft/vscode-azext-github": "^1.0.0",
"@microsoft/vscode-azext-utils": "^2.5.10",
"@microsoft/vscode-azext-utils": "^2.5.11",
"@microsoft/vscode-azureresources-api": "^2.0.2",
"buffer": "^6.0.3",
"dayjs": "^1.11.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { type ManagedEnvironment } from "@azure/arm-appcontainers";
import { LocationListStep, ResourceGroupCreateStep } from "@microsoft/vscode-azext-azureutils";
import { AzureWizard, createSubscriptionContext, nonNullProp, subscriptionExperience, type AzureWizardExecuteStep, type AzureWizardPromptStep, type IActionContext } from "@microsoft/vscode-azext-utils";
import { type AzureSubscription } from "@microsoft/vscode-azureresources-api";
Expand All @@ -16,7 +17,7 @@ import { type ManagedEnvironmentCreateContext } from "./ManagedEnvironmentCreate
import { ManagedEnvironmentCreateStep } from "./ManagedEnvironmentCreateStep";
import { ManagedEnvironmentNameStep } from "./ManagedEnvironmentNameStep";

export async function createManagedEnvironment(context: IActionContext, node?: { subscription: AzureSubscription }): Promise<void> {
export async function createManagedEnvironment(context: IActionContext, node?: { subscription: AzureSubscription }): Promise<ManagedEnvironment> {
const subscription = node?.subscription ?? await subscriptionExperience(context, ext.rgApiV2.resources.azureResourceTreeDataProvider);

const wizardContext: ManagedEnvironmentCreateContext = {
Expand Down Expand Up @@ -54,4 +55,5 @@ export async function createManagedEnvironment(context: IActionContext, node?: {
await wizard.execute();

ext.branchDataProvider.refresh();
return nonNullProp(wizardContext, 'managedEnvironment');
}
8 changes: 3 additions & 5 deletions test/global.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ import * as assert from 'assert';
import * as vscode from 'vscode';
import { ext, registerOnActionStartHandler, registerUIExtensionVariables } from '../extension.bundle';

// const longRunningLocalTestsEnabled: boolean = !/^(false|0)?$/i.test(process.env.AzCode_EnableLongRunningTestsLocal || '');
// const longRunningRemoteTestsEnabled: boolean = !/^(false|0)?$/i.test(process.env.AzCode_UseAzureFederatedCredentials || '');
const longRunningLocalTestsEnabled: boolean = !/^(false|0)?$/i.test(process.env.AzCode_EnableLongRunningTestsLocal || '');
const longRunningRemoteTestsEnabled: boolean = !/^(false|0)?$/i.test(process.env.AzCode_UseAzureFederatedCredentials || '');

// export const longRunningTestsEnabled: boolean = longRunningLocalTestsEnabled || longRunningRemoteTestsEnabled;

export const longRunningTestsEnabled: boolean = false;
export const longRunningTestsEnabled: boolean = longRunningLocalTestsEnabled || longRunningRemoteTestsEnabled;

// Runs before all tests
suiteSetup(async function (this: Mocha.Context): Promise<void> {
Expand Down
97 changes: 97 additions & 0 deletions test/nightly/deployWorkspaceProject/buildParallelScenarios.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { runWithTestActionContext } from "@microsoft/vscode-azext-dev";
import * as assert from "assert";
import * as path from "path";
import { workspace, type Uri, type WorkspaceFolder } from "vscode";
import { AzExtFsExtra, deployWorkspaceProject, dwpSettingUtilsV2, ext, parseError, settingUtils, type DeploymentConfigurationSettings, type DeployWorkspaceProjectResults, type IParsedError } from "../../../extension.bundle";
import { assertStringPropsMatch, getWorkspaceFolderUri } from "../../testUtils";
import { resourceGroupsToDelete } from "../global.nightly.test";
import { dwpTestScenarios, type DeployWorkspaceProjectTestScenario } from "./dwpTestScenarios";

export interface DwpParallelTestScenario {
title: string;
callback(setupTask: Promise<void>): Promise<void>;
scenario?: Promise<void>;
}

export function buildParallelTestScenarios(): DwpParallelTestScenario[] {
return dwpTestScenarios.map(scenario => {
return {
title: scenario.label,
callback: buildParallelScenarioCallback(scenario),
};
});
}

function buildParallelScenarioCallback(scenario: DeployWorkspaceProjectTestScenario): DwpParallelTestScenario['callback'] {
return async (setupTask: Promise<void>) => {
await setupTask;

const workspaceFolderUri: Uri = getWorkspaceFolderUri(scenario.folderName);
const rootFolder: WorkspaceFolder | undefined = workspace.getWorkspaceFolder(workspaceFolderUri);
assert.ok(rootFolder, 'Could not retrieve root workspace folder.');

await cleanWorkspaceFolderSettings(rootFolder);

for (const testCase of scenario.testCases) {
ext.outputChannel.appendLog(`[[[ *** ${scenario.label} - ${testCase.label} *** ]]]`);
await runWithTestActionContext('deployWorkspaceProject', async context => {
await context.ui.runWithInputs(testCase.inputs, async () => {
let results: DeployWorkspaceProjectResults;
let perr: IParsedError | undefined;
try {
results = await deployWorkspaceProject(context);
} catch (e) {
results = {};

perr = parseError(e);
console.log(perr);
}

if (testCase.resourceGroupToDelete) {
resourceGroupsToDelete.add(testCase.resourceGroupToDelete);
}

// Verify 'expectedErrMsg'
if (perr || testCase.expectedErrMsg) {
if (testCase.expectedErrMsg instanceof RegExp) {
assert.match(perr?.message ?? "", testCase.expectedErrMsg, 'DeployWorkspaceProject thrown and expected error message did not match.');
} else {
assert.strictEqual(perr?.message ?? "", testCase.expectedErrMsg, 'DeployWorkspaceProject thrown and expected error message did not match.');
}
}

// Verify 'expectedResults'
assertStringPropsMatch(results as Partial<Record<string, string>>, (testCase.expectedResults ?? {}) as Record<string, string | RegExp>, 'DeployWorkspaceProject results mismatch.');

// Verify 'expectedVSCodeSettings'
const deploymentConfigurationsV2: DeploymentConfigurationSettings[] = await dwpSettingUtilsV2.getWorkspaceDeploymentConfigurations(rootFolder) ?? [];
const expectedDeploymentConfigurations = testCase.expectedVSCodeSettings?.deploymentConfigurations ?? [];
assert.strictEqual(deploymentConfigurationsV2.length, expectedDeploymentConfigurations.length, 'DeployWorkspaceProject ".vscode" saved settings mismatch.');

for (const [i, expectedDeploymentConfiguration] of expectedDeploymentConfigurations.entries()) {
const deploymentConfiguration: DeploymentConfigurationSettings = deploymentConfigurationsV2[i] ?? {};
assertStringPropsMatch(deploymentConfiguration as Partial<Record<string, string>>, expectedDeploymentConfiguration, 'DeployWorkspaceProject ".vscode" saved settings mismatch.');
}

// Verify 'postTestAssertion'
await testCase.postTestAssertion?.(context, results, 'DeployWorkspaceProject resource settings mismatch.');
});
});
}

await cleanWorkspaceFolderSettings(rootFolder);
}
}

async function cleanWorkspaceFolderSettings(rootFolder: WorkspaceFolder) {
const settingsPath: string = settingUtils.getDefaultRootWorkspaceSettingsPath(rootFolder);
const vscodeFolderPath: string = path.dirname(settingsPath);
if (await AzExtFsExtra.pathExists(vscodeFolderPath)) {
await AzExtFsExtra.deleteResource(vscodeFolderPath, { recursive: true });
}
}
Loading