sleeveforarm
Version:
Making Azure Easy
80 lines • 4.38 kB
JavaScript
"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");
const fs = require("fs-extra");
const Path = require("path");
const CliUtilities = require("../src/cliUtilities");
const CommonUtilities = require("../src/common-utilities");
const MySqlAzureInfrastructure = require("../src/mysql-azureinfrastructure");
const Resource = require("../src/resource");
const TestUtilities = require("./testUtilities");
describe("mySQL Azure", () => {
before(function () {
return __awaiter(this, void 0, void 0, function* () {
this.timeout(60 * 1000);
yield CommonUtilities.exec("npm link", Path.join(__dirname, ".."));
});
});
let testingDirFullPath;
let sleeveCommandLocation;
let resourcesInEnvironment;
beforeEach(function () {
return __awaiter(this, void 0, void 0, function* () {
[testingDirFullPath, sleeveCommandLocation] =
yield TestUtilities.setupMochaTestLogging(this);
});
});
afterEach(function () {
return __awaiter(this, void 0, void 0, function* () {
yield TestUtilities.tearDownMochaTestLogging(resourcesInEnvironment, testingDirFullPath, this);
});
});
const sqlFile = "CREATE DATABASE IF NOT EXISTS foo;\n\
use foo;\n\
CREATE TABLE IF NOT EXISTS fooers (name VARCHAR(255));\n\
INSERT INTO fooers (name) VALUES ('A Name');\n";
const testSqlFile = "use foo;\n\
SELECT * FROM fooers\n";
const sleeveJSFile = 'const MySqlAzure = require("sleeveforarm/src/mysql-azure").default;\n\
module.exports = new MySqlAzure().addMySqlInitializationScript("sqlFile");\n';
it("should be deployable", function () {
return __awaiter(this, void 0, void 0, function* () {
const deploymentType = Resource.DeployType.Production;
this.timeout(10 * 60 * 1000);
const mySqlSamplePath = Path.join(testingDirFullPath, TestUtilities.generateRandomTestGroupName());
yield fs.emptyDir(mySqlSamplePath);
yield CommonUtilities.exec(`${sleeveCommandLocation} init`, mySqlSamplePath);
// tslint:disable-next-line:max-line-length
yield CommonUtilities.exec(`${sleeveCommandLocation} setup -t mySqlAzure -n mySql`, mySqlSamplePath);
// await CliUtilities.setup(mySqlSamplePath, "mySql", "mySqlAzure");
const sqlDir = Path.join(mySqlSamplePath, "mySql");
yield fs.writeFile(Path.join(sqlDir, "sqlFile"), sqlFile);
const sqlSleeveJs = Path.join(sqlDir, "sleeve.js");
yield fs.remove(sqlSleeveJs);
yield fs.writeFile(sqlSleeveJs, sleeveJSFile);
const testSqlFilePath = Path.join(sqlDir, "testSqlFile");
yield fs.writeFile(testSqlFilePath, testSqlFile);
// await CommonUtilities.exec(`${sleeveCommandLocation} deploy`,
// webAppSamplePath);
resourcesInEnvironment =
yield CliUtilities.deployResources(mySqlSamplePath, deploymentType, false);
const sqlResource = resourcesInEnvironment.find((resource) => CommonUtilities.isClass(resource,
// tslint:disable-next-line:max-line-length
MySqlAzureInfrastructure.MySqlAzureInfrastructure));
// tslint:disable-next-line:no-unused-expression
chai_1.expect(sqlResource).to.not.be.undefined;
yield sqlResource.setFirewallAllowAll();
const result = yield sqlResource.runMySqlScript(testSqlFilePath);
chai_1.expect(result.stdout).includes("name").and.includes("A Name");
});
});
});
//# sourceMappingURL=mysql-azureTest.js.map