Skip to content

Commit

Permalink
test/db-migrations: assertRowsMatch(): use clearer var name
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn committed Jan 14, 2025
1 parent 5b32ae0 commit dd279c0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/db-migrations/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,22 @@ function assertRowsMatch(actualRows, expectedRows) {

const remainingRows = [...actualRows];
for (let i=0; i<expectedRows.length; ++i) { // eslint-disable-line no-plusplus
const x = expectedRows[i];
const expectedRow = expectedRows[i];
let found = false;
for (let j=0; j<remainingRows.length; ++j) { // eslint-disable-line no-plusplus
const rr = remainingRows[j];
try {
assertIncludes(rr, x); // eslint-disable-line no-use-before-define
assertIncludes(rr, expectedRow); // eslint-disable-line no-use-before-define
remainingRows.splice(j, 1);
found = true;
break;
} catch (err) { /* keep searching */ }
}
if (!found) {
const filteredRemainingRows = remainingRows.map(r => _.pick(r, Object.keys(x)));
const filteredRemainingRows = remainingRows.map(r => _.pick(r, Object.keys(expectedRow)));
assert.fail(
`Expected row ${i} not found:\njson=` +
JSON.stringify({ remainingRows, filteredRemainingRows, expectedRow: x }),
JSON.stringify({ remainingRows, filteredRemainingRows, expectedRow }),
);
}
}
Expand Down

0 comments on commit dd279c0

Please sign in to comment.