-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathdeployWorkspaceProject.test.ts
More file actions
58 lines (49 loc) · 2.59 KB
/
deployWorkspaceProject.test.ts
File metadata and controls
58 lines (49 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { type ManagedEnvironment } from "@azure/arm-appcontainers";
import { runWithTestActionContext } from "@microsoft/vscode-azext-dev";
import { nonNullProp, randomUtils } from "@microsoft/vscode-azext-utils";
import * as assert from "assert";
import { createManagedEnvironment } from "../../../extension.bundle";
import { longRunningTestsEnabled } from '../../global.test';
import { resourceGroupsToDelete } from "../global.nightly.test";
import { buildParallelTestScenarios, type DwpParallelTestScenario } from './buildParallelScenarios';
let setupTask: Promise<void>;
const testScenarios: DwpParallelTestScenario[] = buildParallelTestScenarios();
suite('deployWorkspaceProject', async function (this: Mocha.Suite) {
this.timeout(15 * 60 * 1000);
suiteSetup(async function (this: Mocha.Context) {
if (!longRunningTestsEnabled) {
this.skip();
}
// Create a managed environment first so that we can guarantee one is always built before workspace deployment tests start.
// This is crucial for test consistency because the managed environment prompt will skip if no managed environment
// resources are available yet. Creating at least one environment first ensures consistent reproduceability.
setupTask = setupManagedEnvironment();
for (const s of testScenarios) {
s.scenario = s.callback(setupTask);
}
});
for (const s of testScenarios) {
test(s.title, async function () {
await nonNullProp(s, 'scenario');
});
}
});
async function setupManagedEnvironment(): Promise<void> {
let managedEnvironment: ManagedEnvironment | undefined;
try {
await runWithTestActionContext('createManagedEnvironment', async context => {
const resourceName: string = 'dwp' + randomUtils.getRandomHexString(6);
await context.ui.runWithInputs([resourceName, 'East US'], async () => {
managedEnvironment = await createManagedEnvironment(context);
});
});
} catch (e) {
console.error(e);
}
assert.ok(managedEnvironment, 'Failed to create managed environment - skipping "deployWorkspaceProject" tests.');
resourceGroupsToDelete.add(nonNullProp(managedEnvironment, 'name'));
}