refactor: adjust code to updated dependencies

This commit is contained in:
Karl-Philipp Wulfert
2019-05-27 18:01:58 +02:00
parent 3fda81d279
commit 13b4d3d498
7 changed files with 40 additions and 40 deletions

View File

@@ -13,6 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {asyncPool} from '@krlwlfrt/async-pool';
import {Logger} from '@openstapps/logger';
import {PathLike} from 'fs';
import {Schema, Validator as JSONSchemaValidator, ValidatorResult} from 'jsonschema';
import * as mustache from 'mustache';
@@ -20,7 +21,6 @@ import {basename, join, resolve} from 'path';
import {
ExpectableValidationErrors,
globPromisified,
logger,
readFilePromisified,
writeFilePromisified,
} from './common';
@@ -58,7 +58,7 @@ export class Validator {
throw new Error(`No schema files in ${schemaDir.toString()}!`);
}
logger.log(`Adding schemas from ${schemaDir} to validator.`);
Logger.log(`Adding schemas from ${schemaDir} to validator.`);
// Iterate over schema files
await asyncPool(2, schemaFiles, async (file) => {
@@ -72,7 +72,7 @@ export class Validator {
// add schema to map
this.schemas[basename(file, '.json')] = schema;
logger.info(`Added ${file} to validator.`);
Logger.info(`Added ${file} to validator.`);
});
return schemaFiles;
@@ -117,7 +117,7 @@ export async function validateFiles(schemaDir: string, resourcesDir: string): Pr
throw new Error(`No test files in ${resourcesDir}!`);
}
logger.log(`Found ${testFiles.length} file(s) to test.`);
Logger.log(`Found ${testFiles.length} file(s) to test.`);
// map of errors per file
const errors: ExpectableValidationErrors = {};
@@ -156,7 +156,7 @@ export async function validateFiles(schemaDir: string, resourcesDir: string): Pr
expected = true;
} else {
unexpectedErrors++;
logger.error(`Unexpected error ${error.name} in ${testFile}`);
Logger.error(`Unexpected error ${error.name} in ${testFile}`);
}
// add error to list of errors
@@ -169,7 +169,7 @@ export async function validateFiles(schemaDir: string, resourcesDir: string): Pr
if (expectedErrors.length > 0) {
expectedErrors.forEach((error) => {
logger.error(`Extraneous expected error '${error}' in ${testFile}.`);
Logger.error(`Extraneous expected error '${error}' in ${testFile}.`);
errors[testFileName].push({
argument: false,
expected: false,
@@ -181,7 +181,7 @@ export async function validateFiles(schemaDir: string, resourcesDir: string): Pr
});
});
} else if (unexpectedErrors === 0) {
logger.info(`Successfully validated ${testFile}.`);
Logger.info(`Successfully validated ${testFile}.`);
}
});
@@ -231,5 +231,5 @@ export async function writeReport(reportPath: PathLike, errors: ExpectableValida
timestamp: (new Date()).toISOString(),
}));
logger.ok(`Wrote report to ${reportPath}.`);
Logger.ok(`Wrote report to ${reportPath}.`);
}