An open-source, faster Devin alternative
TypeScript
fix test error
Brian Reardon2e42ef3368e9
diff --git a/cloudflare-workers/api-edge/src/index.test.ts b/cloudflare-workers/api-edge/src/index.test.tsindex 3ade0855..ccd0ccf0 100644--- a/cloudflare-workers/api-edge/src/index.test.ts+++ b/cloudflare-workers/api-edge/src/index.test.ts@@ -78,6 +78,16 @@ class FakeStatement {}return {};}++ // Mirrors D1's batch() per-statement result shape ({ results: [...] }):+ // list queries use all(); single-row queries wrap first() in an array.+ async batchResult<T>(): Promise<{ results: T[] }> {+ if (this.sql.includes("WHERE status = 'active'")) {+ return (await this.all<T>()) as { results: T[] };+ }+ const row = await this.first<T>();+ return { results: row ? [row] : [] };+ }}const env = {@@ -85,6 +95,9 @@ const env = {prepare(sql: string) {return new FakeStatement(sql);},+ async batch(stmts: FakeStatement[]) {+ return Promise.all(stmts.map((s) => s.batchResult()));+ },},SESSIONS_KV: {},CREDIT_ACCOUNT: {},