MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / createSqliteDb

Function createSqliteDb

packages/core/src/query/__tests__/session-index.test.ts:74–100  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72}
73
74function createSqliteDb(): TestSqliteDb {
75 const db = new TestSqliteDb(new Database(':memory:'))
76 db.exec(`
77 CREATE TABLE message (
78 id INTEGER PRIMARY KEY,
79 ts INTEGER NOT NULL
80 );
81 CREATE TABLE segment (
82 id INTEGER PRIMARY KEY AUTOINCREMENT,
83 start_ts INTEGER NOT NULL,
84 end_ts INTEGER NOT NULL,
85 message_count INTEGER NOT NULL,
86 is_manual INTEGER DEFAULT 0,
87 summary TEXT
88 );
89 CREATE TABLE message_context (
90 message_id INTEGER NOT NULL,
91 segment_id INTEGER NOT NULL,
92 topic_id INTEGER
93 );
94 CREATE TABLE meta (
95 session_gap_threshold INTEGER
96 );
97 INSERT INTO meta (session_gap_threshold) VALUES (NULL);
98 `)
99 return db
100}
101
102function seedMessages(db: DatabaseAdapter, msgs: Array<{ id: number; ts: number }>) {
103 const insert = db.prepare('INSERT INTO message (id, ts) VALUES (?, ?)')

Callers 1

Calls 1

execMethod · 0.95

Tested by

no test coverage detected