@vbilopav/pgmigrations
Advanced tools
Comparing version 0.8.0 to 0.8.1
{ | ||
"name": "@vbilopav/pgmigrations", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"description": "PostgreSQL Migration Tool for Node.js and NPM", | ||
@@ -5,0 +5,0 @@ "author": "vb-consulting", |
23
tests.js
@@ -37,3 +37,3 @@ const { warning, info, error, passed, failed } = require("./log.js"); | ||
return str.replace(/{([^{}]+)}/g, function(match, key) { | ||
var val = obj[key]; | ||
let val = obj[key]; | ||
if (val === undefined) { | ||
@@ -50,3 +50,3 @@ return match; | ||
module.exports = async function(opt, config) { | ||
var tests = JSON.parse(await query(formatStrByName(testListQuery, { | ||
let tests = JSON.parse(await query(formatStrByName(testListQuery, { | ||
testFunctionsSchemaSimilarTo: config.testFunctionsSchemaSimilarTo, | ||
@@ -68,8 +68,8 @@ testFunctionsNameSimilarTo: config.testFunctionsNameSimilarTo, | ||
var failedCount = 0; | ||
var passedCount = 0; | ||
var label = "Total " + tests.length.toString() + " tests"; | ||
let failedCount = 0; | ||
let passedCount = 0; | ||
let label = "Total " + tests.length.toString() + " tests"; | ||
console.time(label); | ||
await Promise.all(tests.map(async (test) => { | ||
var cmd; | ||
let cmd; | ||
if (test.type == "FUNCTION") { | ||
@@ -88,9 +88,14 @@ if (config.testAutomaticallyRollbackFunctionTests) { | ||
var testInfo = `${test.schema == "public" ? "" : test.schema + "."}${test.name}${test.comment ? " (" + test.comment.replace(/[\r\n\t]/g, " ").trim() + ")" : ""}`; | ||
var result = await command(cmd, opt, ["--tuples-only", "--no-align"], config, true, true); | ||
let testInfo = `${test.schema == "public" ? "" : test.schema + "."}${test.name}${test.comment ? " (" + test.comment.replace(/[\r\n\t]/g, " ").trim() + ")" : ""}`; | ||
let result = await command(cmd, opt, ["--tuples-only", "--no-align"], config, true, true); | ||
if (result.code != 0 || result.stderr || result.stdout == "f" || result.stdout.toLowerCase().startsWith("not ok")) { | ||
let lower = result.stderr ? result.stderr.toLowerCase() : ""; | ||
if (result.code != 0 || result.stdout == "f" || result.stdout.toLowerCase().startsWith("not ok")) { | ||
failed(testInfo); | ||
error(result.stderr || result.stdout); | ||
failedCount++; | ||
} else if (lower.indexOf("error:") > -1 || lower.indexOf("fatal:") > -1 || lower.indexOf("panic:") > -1) { | ||
failed(testInfo); | ||
error(result.stderr || result.stdout); | ||
failedCount++; | ||
} else { | ||
@@ -97,0 +102,0 @@ passed(testInfo); |
75921
1342