Clean up temporary files and logs - Remove test PDF files, log files, and temporary scripts - Keep important documentation and configuration files - Clean up root directory test files and logs - Maintain project structure integrity
This commit is contained in:
@@ -1,97 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Setup test data for agentic RAG database integration tests
|
||||
* Creates test users and documents with proper UUIDs
|
||||
*/
|
||||
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
const db = require('./dist/config/database').default;
|
||||
const bcrypt = require('bcrypt');
|
||||
|
||||
async function setupTestData() {
|
||||
console.log('🔧 Setting up test data for agentic RAG database integration...\n');
|
||||
|
||||
try {
|
||||
// Create test user
|
||||
console.log('1. Creating test user...');
|
||||
const testUserId = uuidv4();
|
||||
const hashedPassword = await bcrypt.hash('testpassword123', 12);
|
||||
|
||||
await db.query(`
|
||||
INSERT INTO users (id, email, password_hash, name, role, created_at, updated_at)
|
||||
VALUES ($1, $2, $3, $4, $5, NOW(), NOW())
|
||||
ON CONFLICT (email) DO NOTHING
|
||||
`, [testUserId, 'test@agentic-rag.com', hashedPassword, 'Test User', 'admin']);
|
||||
|
||||
// Create test document
|
||||
console.log('2. Creating test document...');
|
||||
const testDocumentId = uuidv4();
|
||||
|
||||
await db.query(`
|
||||
INSERT INTO documents (id, user_id, original_file_name, file_path, file_size, status, extracted_text, created_at, updated_at)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, NOW(), NOW())
|
||||
`, [
|
||||
testDocumentId,
|
||||
testUserId,
|
||||
'test-cim-document.pdf',
|
||||
'/uploads/test-cim-document.pdf',
|
||||
1024000,
|
||||
'completed',
|
||||
'This is a test CIM document for agentic RAG testing.'
|
||||
]);
|
||||
|
||||
// Create test document for full flow
|
||||
console.log('3. Creating test document for full flow...');
|
||||
const testDocumentId2 = uuidv4();
|
||||
|
||||
await db.query(`
|
||||
INSERT INTO documents (id, user_id, original_file_name, file_path, file_size, status, extracted_text, created_at, updated_at)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, NOW(), NOW())
|
||||
`, [
|
||||
testDocumentId2,
|
||||
testUserId,
|
||||
'test-cim-document-full.pdf',
|
||||
'/uploads/test-cim-document-full.pdf',
|
||||
2048000,
|
||||
'completed',
|
||||
'This is a comprehensive test CIM document for full agentic RAG flow testing.'
|
||||
]);
|
||||
|
||||
console.log('✅ Test data setup completed successfully!');
|
||||
console.log('\n📋 Test Data Summary:');
|
||||
console.log(` Test User ID: ${testUserId}`);
|
||||
console.log(` Test Document ID: ${testDocumentId}`);
|
||||
console.log(` Test Document ID (Full Flow): ${testDocumentId2}`);
|
||||
console.log(` Test User Email: test@agentic-rag.com`);
|
||||
console.log(` Test User Password: testpassword123`);
|
||||
|
||||
// Export the IDs for use in tests
|
||||
module.exports = {
|
||||
testUserId,
|
||||
testDocumentId,
|
||||
testDocumentId2
|
||||
};
|
||||
|
||||
return { testUserId, testDocumentId, testDocumentId2 };
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Failed to setup test data:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// Run setup if called directly
|
||||
if (require.main === module) {
|
||||
setupTestData()
|
||||
.then(() => {
|
||||
console.log('\n✨ Test data setup completed!');
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('❌ Test data setup failed:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = { setupTestData };
|
||||
Reference in New Issue
Block a user