Files
Matthew PodwysockiandGitHub 7d5caf327b [containerinstance] Migrate containerinstance projects to use snippets extraction (#32675)
### Packages impacted by this PR

- @azure/arm-containerinstance

### 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 `containerinstance` 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-22 18:39:03 -05:00

146 lines
4.2 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 { ContainerInstanceManagementClient } from "../src/containerInstanceManagementClient.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("ContainerInstance test", () => {
let recorder: Recorder;
let subscriptionId: string;
let client: ContainerInstanceManagementClient;
let location: string;
let resourceGroup: string;
let containerGroupName: string;
let containerInstanceName: 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 ContainerInstanceManagementClient(
credential,
subscriptionId,
recorder.configureClientOptions({}),
);
location = "eastus2";
resourceGroup = "myjstest";
containerGroupName = "mycontainerGroupxxx";
containerInstanceName = "my-containerinstancexx";
});
afterEach(async () => {
await recorder.stop();
});
it("containerGroups create test", async function () {
const res = await client.containerGroups.beginCreateOrUpdateAndWait(
resourceGroup,
containerGroupName,
{
location: location,
identity: {
type: "SystemAssigned",
},
containers: [
{
name: containerInstanceName,
command: [],
environmentVariables: [],
image: "nginx",
ports: [
{
port: 80,
},
],
resources: {
requests: {
cpu: 1,
memoryInGB: 1.5,
// gpu: {
// count: 1,
// sku: "K80"
// }
},
},
volumeMounts: [
{
name: "empty-volume",
mountPath: "mnt/mydir",
},
],
},
],
diagnostics: {
logAnalytics: {
workspaceId: "workspaceid",
workspaceKey: "workspaceKey",
},
},
osType: "Linux",
restartPolicy: "OnFailure",
volumes: [
{
name: "empty-volume",
emptyDir: {},
},
],
},
testPollingOptions,
);
assert.equal(res.name, containerGroupName);
});
it("containerGroups get test", async function () {
const res = await client.containerGroups.get(resourceGroup, containerGroupName);
assert.equal(res.name, containerGroupName);
});
it("containerGroups list test", async function () {
const resArray = new Array();
for await (const item of client.containerGroups.listByResourceGroup(resourceGroup)) {
resArray.push(item);
}
assert.equal(resArray.length, 1);
});
it("containerGroups delete test", async function () {
const resArray = new Array();
await client.containerGroups.beginDeleteAndWait(
resourceGroup,
containerGroupName,
testPollingOptions,
);
for await (const item of client.containerGroups.listByResourceGroup(resourceGroup)) {
resArray.push(item);
}
assert.equal(resArray.length, 0);
});
});