Fix tests

This commit is contained in:
Taylor Bantle
2023-07-11 13:41:28 -07:00
parent 1faab30698
commit a7d0675b2c
2 changed files with 15 additions and 12 deletions

View File

@@ -26,6 +26,13 @@ export function assertQueryResult(q, resultStr, expected, rows, matcher) {
if (q.toLowerCase().includes("dolt_commit")) {
return rows.length === 1 && rows[0].hash.length === 32;
}
if (q.toLowerCase().includes("dolt_merge")) {
const result = JSON.parse(resultStr);
return (
expected.fast_forward === result.fast_forward &&
expected.conflicts === result.conflicts
);
}
return resultStr === JSON.stringify(expected);
}

View File

@@ -47,7 +47,14 @@ async function runTests(database, tests) {
assertEqualRows(test, rows);
})
.catch((err) => {
handleError(test, err);
if (test.expectedErr) {
if (err.message.includes(test.expectedErr)) {
return;
} else {
console.log("Query error did not match expected:", test.q);
}
}
console.error(err);
process.exit(1);
});
})
@@ -64,14 +71,3 @@ function assertEqualRows(test, rows) {
throw new Error(`Query failed: ${test.q}`);
}
}
function handleError(test, err) {
if (test.expectedErr) {
if (err.message.includes(test.expectedErr)) {
return;
} else {
console.log("Query error did not match expected:", test.q);
}
}
console.error(err);
}