| 34 | }; |
| 35 | |
| 36 | const load = async () => { |
| 37 | const cg = await CodeGraph.init(dir, { silent: true }); |
| 38 | await cg.indexAll(); |
| 39 | const db = (cg as any).db.db; |
| 40 | const edges: { src: string; tgt: string; via: string }[] = db |
| 41 | .prepare( |
| 42 | `SELECT s.name src, t.name tgt, json_extract(e.metadata,'$.via') via |
| 43 | FROM edges e JOIN nodes s ON s.id = e.source JOIN nodes t ON t.id = e.target |
| 44 | WHERE json_extract(e.metadata,'$.synthesizedBy') = 'fn-pointer-dispatch'` |
| 45 | ) |
| 46 | .all(); |
| 47 | cg.close?.(); |
| 48 | return edges; |
| 49 | }; |
| 50 | const has = (edges: any[], src: string, tgt: string) => edges.some((e) => e.src === src && e.tgt === tgt); |
| 51 | |
| 52 | it('bridges a {name, fn} command table dispatched through p->fn() (the git shape)', async () => { |