-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_prisma.js
More file actions
executable file
·83 lines (71 loc) · 3.15 KB
/
Copy pathtest_prisma.js
File metadata and controls
executable file
·83 lines (71 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const { PrismaClient } = require('@prisma/client');
const db = new PrismaClient();
async function test() {
const tests = [];
const models = [
'memory', 'contextMemory', 'memoryLink', 'agent', 'schedulerTask',
'researchSession', 'pipeline', 'issuePipeline', 'mcpServer',
'plugin', 'prompt', 'workspace', 'settings', 'provider',
'kanbanBoard', 'knowledgeDocument', 'conversation', 'auditLog',
'collabSession', 'message', 'skill', 'modelRoute', 'quickAction'
];
for (const model of models) {
try {
if (db[model] && db[model].findMany) {
const results = await db[model].findMany({ take: 5 });
tests.push({ name: model + '.findMany', status: 'PASS', count: results.length });
} else {
tests.push({ name: model, status: 'SKIP', error: 'Model not found in Prisma client' });
}
} catch(e) {
tests.push({ name: model + '.findMany', status: 'FAIL', error: e.message.slice(0, 100) });
}
}
// Test CRUD cycle on Memory model
try {
const m = await db.memory.create({ data: { key: 'crud-test-' + Date.now(), content: 'Test content', source: 'test' } });
tests.push({ name: 'Memory.create', status: 'PASS', id: m.id });
const found = await db.memory.findUnique({ where: { id: m.id } });
tests.push({ name: 'Memory.findUnique', status: found ? 'PASS' : 'FAIL' });
const updated = await db.memory.update({ where: { id: m.id }, data: { content: 'Updated content' } });
tests.push({ name: 'Memory.update', status: updated.content === 'Updated content' ? 'PASS' : 'FAIL' });
await db.memory.delete({ where: { id: m.id } });
tests.push({ name: 'Memory.delete', status: 'PASS' });
} catch(e) {
tests.push({ name: 'Memory CRUD cycle', status: 'FAIL', error: e.message.slice(0, 100) });
}
// Test ContextMemory CRUD
try {
const cm = await db.contextMemory.create({
data: {
type: 'episodic',
category: 'conversation',
content: 'Test context memory',
priority: 3,
tags: '["test"]'
}
});
tests.push({ name: 'ContextMemory.create', status: 'PASS', id: cm.id });
await db.contextMemory.delete({ where: { id: cm.id } });
tests.push({ name: 'ContextMemory.delete', status: 'PASS' });
} catch(e) {
tests.push({ name: 'ContextMemory CRUD', status: 'FAIL', error: e.message.slice(0, 100) });
}
// Summary
const pass = tests.filter(t => t.status === 'PASS').length;
const fail = tests.filter(t => t.status === 'FAIL').length;
const skip = tests.filter(t => t.status === 'SKIP').length;
console.log('');
console.log('=== PRISMA DATABASE CRUD TEST RESULTS ===');
for (const t of tests) {
const icon = t.status === 'PASS' ? '✅' : (t.status === 'SKIP' ? '⏭️' : '❌');
let extra = '';
if (t.error) extra = ' → ' + t.error;
else if (t.count !== undefined) extra = ' (' + t.count + ' records)';
console.log(' ' + icon + ' ' + t.name + extra);
}
console.log('');
console.log('PASSED: ' + pass + ' / FAILED: ' + fail + ' / SKIPPED: ' + skip + ' / TOTAL: ' + tests.length);
await db.$disconnect();
}
test().catch(e => { console.error('Fatal:', e); process.exit(1); });