UNPKG

sleeveforarm

Version:
70 lines 3.84 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); require("mocha"); const Path = require("path"); const ReplaceInFile = require("replace-in-file"); const CommonUtilities = require("../src/common-utilities"); const Resource = require("../src/resource"); // tslint:disable-next-line:max-line-length const ResourceGroupInfrastructure = require("../src/resourcegroupInfrastructure"); const TestUtilities = require("./testUtilities"); describe("Resource group", () => { before(function () { return __awaiter(this, void 0, void 0, function* () { this.timeout(60 * 1000); yield CommonUtilities.exec("npm link", Path.join(__dirname, "..")); }); }); let testingDirFullPath; const resourcesInEnvironment = []; beforeEach(function () { return __awaiter(this, void 0, void 0, function* () { [testingDirFullPath] = yield TestUtilities.setupMochaTestLogging(this); }); }); afterEach(function () { return __awaiter(this, void 0, void 0, function* () { yield TestUtilities.tearDownMochaTestLogging(resourcesInEnvironment, testingDirFullPath, this); }); }); it("should create a resource group", () => __awaiter(this, void 0, void 0, function* () { const resourceGroupPath = Path.join(testingDirFullPath, TestUtilities.generateRandomTestGroupName()); const resourceGroupInfra = new ResourceGroupInfrastructure.ResourceGroupInfrastructure(); resourceGroupInfra.initialize(null, resourceGroupPath); yield resourceGroupInfra.setup(); const replaceInFileOptions = { files: Path.join(resourceGroupPath, "sleeve.js"), from: /resourcegroupAzure\(\);/, // tslint:disable-next-line:max-line-length to: "resourcegroupAzure().setDataCenter(DataCenterNames.SouthCentralUS);" }; yield ReplaceInFile(replaceInFileOptions); yield CommonUtilities .exec("npm link sleeveforarm", resourceGroupPath); yield CommonUtilities .exec("npm install", resourceGroupPath); const resourceGroup = require(Path.join(resourceGroupPath, "sleeve.js")); const secondResourceGroupInfra = new ResourceGroupInfrastructure.ResourceGroupInfrastructure(); resourcesInEnvironment.push(secondResourceGroupInfra); secondResourceGroupInfra.initialize(resourceGroup, resourceGroupPath); yield secondResourceGroupInfra.hydrate([], Resource.DeployType.Production); // We aren't waiting because we don't need to, we'll // catch it in getBaseDeployClassInstance secondResourceGroupInfra.deployResource(); const baseClass = yield secondResourceGroupInfra.getBaseDeployClassInstance(); const resourceGroupName = baseClass.deployedResourceGroupName; const result = yield CommonUtilities.runAzCommand(`az group exists --name ${resourceGroupName}`, CommonUtilities.azCommandOutputs.string); chai_1.expect(result.trim()).equals("true"); })); }); //# sourceMappingURL=resourcegroupTest.js.map