Files
Matthew PodwysockiandGitHub 45ebe53260 [devtestlabs] Update devtestlabs projects to use snippets extraction (#32798)
### Packages impacted by this PR

- @azure/arm-devtestlabs

### Issues associated with this PR

- https://github.com/Azure/azure-sdk-for-js/issues/32416

### Describe the problem that is addressed by this PR

Updates all projects under `devtestlabs` to use snippets extraction.

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?


### Are there test cases added in this PR? _(If not, why?)_


### Provide a list of related PRs _(if any)_


### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_

### Checklists
- [ ] Added impacted package name to the issue description
- [ ] Does this PR needs any fixes in the SDK Generator?** _(If so,
create an Issue in the
[Autorest/typescript](https://github.com/Azure/autorest.typescript)
repository and link it here)_
- [ ] Added a changelog (if necessary)
2025-01-30 17:13:43 -05:00

99 lines
3.0 KiB
TypeScript

/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import type { RecorderStartOptions } from "@azure-tools/test-recorder";
import { env, Recorder, isPlaybackMode } from "@azure-tools/test-recorder";
import { createTestCredential } from "@azure-tools/test-credential";
import { DevTestLabsClient } from "../src/devTestLabsClient.js";
import { describe, it, assert, beforeEach, afterEach } from "vitest";
const replaceableVariables: Record<string, string> = {
AZURE_CLIENT_ID: "azure_client_id",
AZURE_CLIENT_SECRET: "azure_client_secret",
AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888",
SUBSCRIPTION_ID: "azure_subscription_id",
};
const recorderOptions: RecorderStartOptions = {
envSetupForPlayback: replaceableVariables,
removeCentralSanitizers: [
"AZSDK3493", // .name in the body is not a secret and is listed below in the beforeEach section
"AZSDK3430", // .id in the body is not a secret and is listed below in the beforeEach section
],
};
export const testPollingOptions = {
updateIntervalInMs: isPlaybackMode() ? 0 : undefined,
};
describe("DevTestLabs test", () => {
let recorder: Recorder;
let subscriptionId: string;
let client: DevTestLabsClient;
let location: string;
let resourceGroup: string;
let name: string;
beforeEach(async (ctx) => {
recorder = new Recorder(ctx);
await recorder.start(recorderOptions);
subscriptionId = env.SUBSCRIPTION_ID || "";
// This is an example of how the environment variables are used
const credential = createTestCredential();
client = new DevTestLabsClient(credential, subscriptionId, recorder.configureClientOptions({}));
location = "eastus";
resourceGroup = "myjstest";
name = "mylabsxxx";
});
afterEach(async () => {
await recorder.stop();
});
it("labs create test", async () => {
const res = await client.labs.beginCreateOrUpdateAndWait(
resourceGroup,
name,
{ location: location },
testPollingOptions,
);
assert.equal(res.name, name);
});
it("labs get test", async () => {
const res = await client.labs.get(resourceGroup, name);
assert.equal(res.name, name);
});
it("labs list test", async () => {
const resArray = new Array();
for await (const item of client.labs.listByResourceGroup(resourceGroup)) {
resArray.push(item);
}
assert.equal(resArray.length, 1);
});
it("labs update test", async () => {
const res = await client.labs.update(resourceGroup, name, {
tags: {
tag1: "vaue1",
},
});
assert.equal(res.type, "Microsoft.DevTestLab/labs");
});
it("labs delete test", async () => {
const resArray = new Array();
await client.labs.beginDeleteAndWait(resourceGroup, name);
for await (const item of client.labs.listByResourceGroup(resourceGroup)) {
resArray.push(item);
}
assert.equal(resArray.length, 0);
});
});