(expect, actual)
| 205 | } |
| 206 | |
| 207 | assertResult(expect, actual) { |
| 208 | const normalizedActual = this.convertResult(actual); |
| 209 | |
| 210 | if (expect.result !== undefined) { |
| 211 | const expectedResult = expect.result; |
| 212 | if (Array.isArray(expectedResult)) { |
| 213 | if (typeof normalizedActual === 'string') { |
| 214 | throw new Error(`Expected result ${JSON.stringify(expectedResult)}, got status '${normalizedActual}'`); |
| 215 | } |
| 216 | const actualStr = JSON.stringify(normalizedActual); |
| 217 | const expectedStr = JSON.stringify(expectedResult); |
| 218 | if (actualStr !== expectedStr) { |
| 219 | throw new Error(`Expected result ${expectedStr}, got ${actualStr}`); |
| 220 | } |
| 221 | } else { |
| 222 | if (String(normalizedActual) !== String(expectedResult)) { |
| 223 | throw new Error(`Expected result '${expectedResult}', got '${normalizedActual}'`); |
| 224 | } |
| 225 | } |
| 226 | } else if (expect.result_contains) { |
| 227 | if (typeof normalizedActual === 'string') { |
| 228 | throw new Error(`Expected result containing ${JSON.stringify(expect.result_contains)}, got status '${normalizedActual}'`); |
| 229 | } |
| 230 | for (const expectedRow of expect.result_contains) { |
| 231 | const found = normalizedActual.some(actualRow => |
| 232 | JSON.stringify(actualRow) === JSON.stringify(expectedRow) |
| 233 | ); |
| 234 | if (!found) { |
| 235 | throw new Error(`Expected row ${JSON.stringify(expectedRow)} not found in actual results.`); |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | async executeLoop(loopDef, variables, sql) { |
| 242 | const loopVarName = loopDef.as; |
no test coverage detected