MCPcopy
hub / github.com/opentrace/opentrace / runTest

Function runTest

ui/src/test-db.ts:242–414  ·  view source on GitHub ↗
(nodeCount: number)

Source from the content-addressed store, hash-verified

240];
241
242async function runTest(nodeCount: number) {
243 logEl.innerHTML = '';
244 log(`=== Test: ${nodeCount} nodes ===`);
245
246 // 1. Init
247 log('Initializing WASM module...');
248 try {
249 // Worker script must be served from the correct path.
250 // In Vite dev mode, node_modules are served directly.
251 lbug.setWorkerPath('/lbug_wasm_worker.js');
252 await lbug.init();
253 const version = await lbug.getVersion();
254 log(`WASM loaded — LadybugDB ${version}`, 'ok');
255 } catch (err) {
256 log(`WASM init failed: ${err}`, 'err');
257 return;
258 }
259
260 let db: InstanceType<typeof lbug.Database>;
261 let conn: InstanceType<typeof lbug.Connection>;
262
263 try {
264 db = new lbug.Database(':memory:');
265 await db.init();
266 conn = new lbug.Connection(db);
267 await conn.init();
268 log('Database + Connection created', 'ok');
269 } catch (err) {
270 log(`Database/Connection failed: ${err}`, 'err');
271 return;
272 }
273
274 // 2. Schema
275 log('Creating schema...');
276 for (const type of NODE_TYPES) {
277 const r = await conn.query(
278 `CREATE NODE TABLE IF NOT EXISTS ${type}(id STRING PRIMARY KEY, name STRING, properties STRING)`,
279 );
280 await r.close();
281 }
282 const pairs = [
283 'FROM Function TO Function',
284 'FROM Function TO File',
285 'FROM Function TO Class',
286 'FROM Class TO File',
287 'FROM Class TO Class',
288 'FROM File TO Directory',
289 'FROM File TO File',
290 'FROM File TO Package',
291 'FROM File TO Repository',
292 'FROM Directory TO Directory',
293 'FROM Directory TO Repository',
294 'FROM Repository TO Package',
295 ].join(', ');
296 const relResult = await conn.query(
297 `CREATE REL TABLE GROUP IF NOT EXISTS RELATES(${pairs}, id STRING, type STRING, properties STRING)`,
298 );
299 await relResult.close();

Callers

nothing calls this directly

Calls 11

logFunction · 0.85
generateDatasetFunction · 0.85
nodeCSVFunction · 0.85
relCSVFunction · 0.85
getVersionMethod · 0.80
pushMethod · 0.80
getAllObjectsMethod · 0.80
initMethod · 0.65
queryMethod · 0.65
closeMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected