Commit cb52978
🧪 add test for query timeout in wasm database engine (#171)
The `executeQuery` method in `src/core/sqlite-db.ts` contains logic to throw an error if row iteration (`stmt.step()`) exceeds the configured `queryTimeout`. However, this specific code path lacked unit test coverage.
This commit adds a test case to `tests/unit/sqlite-db.test.ts` within the `WasmDatabaseEngine` suite. The test simulates a slow query by mocking `Date.now()` globally inside a `try...finally` block, ensuring it artificially increments past the 100ms timeout configured on the test engine instance. It accurately asserts that the `assert.rejects` catches the specific timeout error message: `Query execution timed out after 100ms`.
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>1 parent 2e88f3c commit cb52978
1 file changed
Lines changed: 46 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
130 | 176 | | |
0 commit comments