MCPcopy Create free account
hub / github.com/chokcoco/iCSS / InspirationTester

Class InspirationTester

MCP/test-inspiration.js:10–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8const __dirname = path.dirname(__filename);
9
10class InspirationTester {
11 constructor() {
12 this.dbPath = path.join(__dirname, 'data', 'icss.db');
13 this.db = new Database.Database(this.dbPath, (err) => {
14 if (err) {
15 console.error('❌ Error opening database:', err);
16 process.exit(1);
17 }
18 });
19 }
20
21 async testDatabaseIntegrity() {
22 console.log('🔍 Testing database integrity...\n');
23
24 // 测试表是否存在
25 const tables = [
26 'issues',
27 'css_inspiration',
28 'code_snippets',
29 'demo_styles'
30 ];
31
32 for (const table of tables) {
33 await this.checkTable(table);
34 }
35 }
36
37 checkTable(tableName) {
38 return new Promise((resolve, reject) => {
39 this.db.get(
40 `SELECT COUNT(*) as count FROM ${tableName}`,
41 (err, row) => {
42 if (err) {
43 console.error(`❌ Table ${tableName} error:`, err.message);
44 reject(err);
45 } else {
46 console.log(`✅ Table ${tableName}: ${row.count} records`);
47 resolve(row.count);
48 }
49 }
50 );
51 });
52 }
53
54 async testSearchFunctionality() {
55 console.log('\n🔍 Testing search functionality...\n');
56
57 // 测试 CSS-Inspiration 搜索
58 await this.testQuery(
59 'CSS-Inspiration Search',
60 `SELECT * FROM css_inspiration WHERE search_content LIKE '%动画%' LIMIT 3`
61 );
62
63 // 测试分类统计
64 await this.testQuery(
65 'Category Statistics',
66 `SELECT category, COUNT(*) as count FROM css_inspiration GROUP BY category ORDER BY count DESC LIMIT 5`
67 );

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected