MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / expectSameRows

Function expectSameRows

__tests__/explore-long-query.test.ts:111–135  ·  view source on GitHub ↗
(cg: CodeGraph, plan: 'rowid' | 'index')

Source from the content-addressed store, hash-verified

109 }
110
111 function expectSameRows(cg: CodeGraph, plan: 'rowid' | 'index'): void {
112 const q = queriesOf(cg);
113 const db = rawDb(cg);
114 let compared = 0;
115 for (const substring of PATTERNS) {
116 for (const kinds of [DEF, CALL, SEED, ['method'], ['constant', 'function']]) {
117 for (const excludePrefix of [false, true]) {
118 for (const limit of [200, 7, 1]) {
119 const expected = likeScan(db, substring, kinds, excludePrefix, limit);
120 const actual = q.findNodesByNameSubstring(substring, { kinds: kinds as never, excludePrefix, limit }).map((r) => r.node.id);
121 expect(actual, `${substring} ${kinds.join(',')} excludePrefix=${excludePrefix} limit=${limit}`).toEqual(expected);
122 compared++;
123 }
124 }
125 }
126 }
127 expect(compared).toBeGreaterThan(900);
128 // The answers came from the index, under the plan SQLite chose.
129 const memo = (q as unknown as { readMemos: Map<string, { value: { plans: Map<string, string | null> } | null }> })
130 .readMemos.get('nameSubstringIndex');
131 expect(memo?.value).toBeTruthy();
132 const plans = [...memo!.value!.plans.values()];
133 expect(plans).toContain(plan);
134 expect(plans).not.toContain(null);
135 }
136
137 it('matches when SQLite scans the table (a small index)', async () => {
138 const cg = await setup();

Callers 1

Calls 7

rawDbFunction · 0.85
likeScanFunction · 0.85
mapMethod · 0.80
queriesOfFunction · 0.70
getMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected