(q, expected, data, matcher)
| 39 | } |
| 40 | |
| 41 | export function assertQueryResult(q, expected, data, matcher) { |
| 42 | if (matcher) { |
| 43 | return matcher(data, expected); |
| 44 | } |
| 45 | if (q.toLowerCase().includes("dolt_commit")) { |
| 46 | if (data.rows.length !== 1) return false; |
| 47 | const hash = data.rows[0].dolt_commit[0]; |
| 48 | if (hash.length !== 32) { |
| 49 | console.log("Invalid hash for dolt_commit:", hash); |
| 50 | return false; |
| 51 | } |
| 52 | expected.rows[0].dolt_commit = data.rows[0].dolt_commit; |
| 53 | } |
| 54 | |
| 55 | // Does partial matching of actual and expected results. |
| 56 | const partialRes = { |
| 57 | command: data.command, |
| 58 | rowCount: data.rowCount, |
| 59 | oid: data.oid, |
| 60 | rows: data.rows, |
| 61 | fields: data.fields, |
| 62 | }; |
| 63 | return JSON.stringify(expected) === JSON.stringify(partialRes); |
| 64 | } |
no test coverage detected