/* * 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 { __asyncValues, __awaiter } from "tslib"; import { env, Recorder, isPlaybackMode, } from "@azure-tools/test-recorder"; import { createTestCredential } from "@azure-tools/test-credential"; import { assert } from "chai"; import { WebSiteManagementClient } from "../src/webSiteManagementClient"; const replaceableVariables = { 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 = { envSetupForPlayback: replaceableVariables }; export const testPollingOptions = { updateIntervalInMs: isPlaybackMode() ? 0 : undefined, }; describe("Web test", () => { let recorder; let subscriptionId; let client; let location; let resourceGroup; let appservicePlanName; let name; beforeEach(function () { return __awaiter(this, void 0, void 0, function* () { recorder = new Recorder(this.currentTest); yield recorder.start(recorderOptions); subscriptionId = env.SUBSCRIPTION_ID || ''; // This is an example of how the environment variables are used const credential = createTestCredential(); client = new WebSiteManagementClient(credential, subscriptionId, recorder.configureClientOptions({})); location = "eastus"; resourceGroup = "myjstest"; appservicePlanName = "myappserviceplanxxx"; name = "mysitexxxx"; }); }); afterEach(function () { return __awaiter(this, void 0, void 0, function* () { yield recorder.stop(); }); }); it("appServicePlans create test", function () { return __awaiter(this, void 0, void 0, function* () { const res = yield client.appServicePlans.beginCreateOrUpdateAndWait(resourceGroup, appservicePlanName, { location: "eastus", sku: { name: "S1", tier: "STANDARD", capacity: 1, }, perSiteScaling: false, isXenon: false }, testPollingOptions); assert.equal(res.name, appservicePlanName); }); }); it("webApps create test", function () { return __awaiter(this, void 0, void 0, function* () { const res = yield client.webApps.beginCreateOrUpdateAndWait(resourceGroup, name, { location: "eastus", serverFarmId: "/subscriptions/" + subscriptionId + "/resourceGroups/myjstest/providers/Microsoft.Web/serverfarms/myappserviceplanxxx", reserved: false, isXenon: false, hyperV: false, siteConfig: { netFrameworkVersion: "v4.6", appSettings: [ { name: "WEBSITE_NODE_DEFAULT_VERSION", value: "10.14", }, ], localMySqlEnabled: false, http20Enabled: true, }, scmSiteAlsoStopped: false, httpsOnly: false }, testPollingOptions); assert.equal(res.name, name); }); }); it("appServicePlans get test", function () { return __awaiter(this, void 0, void 0, function* () { const res = yield client.appServicePlans.get(resourceGroup, appservicePlanName); assert.equal(res.name, appservicePlanName); }); }); it("webApps get test", function () { return __awaiter(this, void 0, void 0, function* () { const res = yield client.webApps.get(resourceGroup, name); assert.equal(res.name, name); }); }); it("appServicePlans list test", function () { var e_1, _a; return __awaiter(this, void 0, void 0, function* () { const resArray = new Array(); try { for (var _b = __asyncValues(client.appServicePlans.listByResourceGroup(resourceGroup)), _c; _c = yield _b.next(), !_c.done;) { let item = _c.value; resArray.push(item); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b); } finally { if (e_1) throw e_1.error; } } assert.equal(resArray.length, 1); }); }); it("webApps list test", function () { var e_2, _a; return __awaiter(this, void 0, void 0, function* () { const resArray = new Array(); try { for (var _b = __asyncValues(client.webApps.listByResourceGroup(resourceGroup)), _c; _c = yield _b.next(), !_c.done;) { let item = _c.value; resArray.push(item); } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b); } finally { if (e_2) throw e_2.error; } } assert.equal(resArray.length, 1); }); }); it("webApps update test", function () { return __awaiter(this, void 0, void 0, function* () { const res = yield client.webApps.update(resourceGroup, name, { serverFarmId: "/subscriptions/" + subscriptionId + "/resourceGroups/myjstest/providers/Microsoft.Web/serverfarms/myappserviceplanxxx", reserved: false, isXenon: false, hyperV: false, siteConfig: { netFrameworkVersion: "v4.6", localMySqlEnabled: false, http20Enabled: true, }, scmSiteAlsoStopped: false }); assert.equal(res.name, name); }); }); it("webApps delete test", function () { var e_3, _a; return __awaiter(this, void 0, void 0, function* () { const res = yield client.webApps.delete(resourceGroup, name); const resArray = new Array(); try { for (var _b = __asyncValues(client.webApps.listByResourceGroup(resourceGroup)), _c; _c = yield _b.next(), !_c.done;) { let item = _c.value; resArray.push(item); } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b); } finally { if (e_3) throw e_3.error; } } assert.equal(resArray.length, 0); }); }); it("appServicePlans delete test", function () { var e_4, _a; return __awaiter(this, void 0, void 0, function* () { const res = yield client.appServicePlans.delete(resourceGroup, appservicePlanName); const resArray = new Array(); try { for (var _b = __asyncValues(client.appServicePlans.listByResourceGroup(resourceGroup)), _c; _c = yield _b.next(), !_c.done;) { let item = _c.value; resArray.push(item); } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b); } finally { if (e_4) throw e_4.error; } } assert.equal(resArray.length, 0); }); }); }); //# sourceMappingURL=web_examples.js.map