godcrm/scripts/backend-tools/test-neometal-connection.js
GOD CRM Release f89e074dd1
Some checks failed
CI / Lint / Typecheck / Test / Build (push) Has been cancelled
CI / PostgreSQL Integration Tests (push) Has been cancelled
GOD CRM — public scrubbed snapshot
Governed substrate for autonomous agents: scoped identity (passports),
audited actions, MCP workspace. Infra IPs and secrets redacted for public release.
2026-08-10 04:01:45 +03:00

68 lines
2.3 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import DirectDatabaseConnector from './backend/services/DirectDatabaseConnector.js';
console.log('🧪 Testing Direct Database Connector with Neometal Database\n');
async function testNeometalConnection() {
const config = {
type: 'mysql2',
host: 'localhost',
port: 3306,
database: 'neometal',
user: 'root',
password: '' // root без пароля
};
console.log('📋 Test Configuration:');
console.log(JSON.stringify(config, null, 2));
console.log('\n1⃣ Testing connection...');
try {
// Test connection
const testResult = await DirectDatabaseConnector.testConnection(config);
console.log('✅ Test Result:', testResult);
if (!testResult.success) {
console.error('❌ Connection test failed');
return;
}
console.log('\n2⃣ Creating persistent connection...');
const testId = 'neometal_test';
await DirectDatabaseConnector.connect(testId, config);
console.log('✅ Connected with ID:', testId);
console.log('\n3⃣ Getting database info...');
const info = await DirectDatabaseConnector.getDatabaseInfo(testId);
console.log('✅ Database Info:', info);
console.log('\n4⃣ Fetching all tables...');
const tables = await DirectDatabaseConnector.getTables(testId);
console.log(`✅ Found ${tables.length} tables`);
console.log('First 10 tables:', tables.slice(0, 10));
console.log('\n5⃣ Getting schema for lvl_products table...');
const productsSchema = await DirectDatabaseConnector.getTableSchema(testId, 'lvl_products');
console.log('✅ lvl_products columns:', productsSchema.length);
console.log('First 5 columns:', productsSchema.slice(0, 5).map(c => `${c.name} (${c.type})`));
console.log('\n6⃣ Executing SELECT query...');
const result = await DirectDatabaseConnector.query(
testId,
'SELECT id, name, price FROM lvl_products LIMIT 5'
);
console.log('✅ Query result:');
console.log(result[0]); // MySQL returns [rows, fields]
console.log('\n7⃣ Disconnecting...');
await DirectDatabaseConnector.disconnect(testId);
console.log('✅ Disconnected');
console.log('\n✨ ALL TESTS PASSED! ✨');
} catch (error) {
console.error('\n❌ Test failed:', error.message);
console.error('Stack:', error.stack);
}
}
// Run test
testNeometalConnection();