Files
Matthew PodwysockiandGitHub 28ddc84580 [devcenter] Update devcenter projects to use snippet extraction (#32784)
### Packages impacted by this PR

- @azure/arm-devcenter
- @azure-rest/developer-devcenter

### 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 `devcenter` 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-29 18:12:47 -05:00

93 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 { DevCenterClient } from "../src/devCenterClient.js";
import type { DevCenter } from "../src/models/index.js";
import { describe, it, assert, beforeEach, afterEach } from "vitest";
const replaceableVariables: Record<string, string> = {
SUBSCRIPTION_ID: "88888888-8888-8888-8888-888888888888",
};
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("devcenter test", () => {
let recorder: Recorder;
let subscriptionId: string;
let client: DevCenterClient;
let location: string;
let resourceGroup: string;
let body: DevCenter;
let devCenterName: 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 DevCenterClient(credential, subscriptionId, recorder.configureClientOptions({}));
location = "eastus";
resourceGroup = "myjstest";
devCenterName = "Contoso1";
body = {
location,
tags: { costCode: "12345" },
};
});
afterEach(async () => {
await recorder.stop();
});
it("devcenters create test", async function () {
const res = await client.devCenters.beginCreateOrUpdateAndWait(
resourceGroup,
devCenterName,
body,
testPollingOptions,
);
assert.equal(res.name, devCenterName);
});
it("devcenters get test", async function () {
const res = await client.devCenters.get(resourceGroup, devCenterName);
assert.equal(res.name, devCenterName);
});
it("devcenters list test", async function () {
const resArray = new Array();
for await (const item of client.devCenters.listByResourceGroup(resourceGroup)) {
resArray.push(item);
}
assert.equal(resArray.length, 1);
});
it("devcenters delete test", async function () {
const resArray = new Array();
await client.devCenters.beginDeleteAndWait(resourceGroup, devCenterName, testPollingOptions);
for await (const item of client.devCenters.listByResourceGroup(resourceGroup)) {
resArray.push(item);
}
assert.equal(resArray.length, 0);
});
});