Merge pull request #142 from Azure/fix-test

fixing test
This commit is contained in:
Zim Kalinowski 2020-02-26 04:11:57 +01:00 коммит произвёл GitHub
Родитель facc9a0885 22bac33b64
Коммит 79f7697574
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 17 добавлений и 15 удалений

Просмотреть файл

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { suite, test } from 'mocha-typescript';
import { suite, test, slow, timeout } from 'mocha-typescript';
import * as assert from 'assert';
import { readFile, writeFile, readdir, mkdir } from "@azure-tools/async-io";
import { deserialize, serialize, fail } from "@azure-tools/codegen";
@ -19,7 +19,7 @@ const resources = `${__dirname}/../../src/test/resources`;
@suite class Process {
@test async simpleModifierTest() {
@test(slow(600000), timeout(1500000)) async simpleModifierTest() {
const folders = await readdir(resources);
for(var each of folders) {
let cfg = {
@ -45,15 +45,15 @@ const resources = `${__dirname}/../../src/test/resources`;
// go!
const codeModel = await modeler.process();
// console.log(serialize(codeModel))
const yaml = serialize(codeModel);
const fileName = `${__dirname}/../../src/test/resources/` + each + "/" + each + `-az-modifier.yaml`;
//await (writeFile(fileName, yaml));
// uncomment this line to overwrite existing file
// await (writeFile(fileName, serialize(codeModel)));
const supposeFile = await readFile(fileName);
//const cms = deserialize<CodeModel>(yaml, 'foo.yaml');
assert.strictEqual(yaml, supposeFile, 'namer has failed the unit test');
const codeModelSupposed = deserialize<CodeModel>(supposeFile, fileName);
assert.deepEqual(codeModel, codeModelSupposed, 'namer has failed the unit test');
}
}
}

Просмотреть файл

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { suite, test } from "mocha-typescript";
import { suite, test, slow, timeout } from "mocha-typescript";
import * as assert from 'assert';
import { readFile, writeFile, readdir, mkdir } from "@azure-tools/async-io";
import { deserialize, serialize, fail } from "@azure-tools/codegen";
@ -19,7 +19,7 @@ const resources = `${__dirname}/../../src/test/resources/`;
@suite class Process {
@test async simpleNamerTest() {
@test(slow(600000), timeout(1500000)) async simpleNamerTest() {
const folders = await readdir(resources);
for(var each of folders) {
@ -38,13 +38,15 @@ const resources = `${__dirname}/../../src/test/resources/`;
const codeModel = await aznamer.process();
// console.log(serialize(codeModel))
const yaml = serialize(codeModel);
const fileName = `${__dirname}/../../src/test/resources/`+ each + "/" + each + `-az-namer.yaml`;
// uncomment this line to overwrite existing file
// await (writeFile(fileName, serialize(codeModel)));
const supposeFile = await readFile(fileName);
//await (writeFile(fileName, yaml));
//const cms = deserialize<CodeModel>(supposeFile, 'foo.yaml');
assert.strictEqual(yaml, supposeFile, 'namer has failed the unit test');
const codeModelSupposed = deserialize<CodeModel>(supposeFile, fileName);
assert.deepEqual(codeModel, codeModelSupposed, 'modifier has failed the unit test');
}
}