41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
// Test script to verify audit functionality with auto-directory opening
|
|
console.log('Testing audit functionality with auto-directory opening...');
|
|
|
|
// Create a temporary test directory
|
|
const testDir = path.join(__dirname, 'test_audit');
|
|
if (!fs.existsSync(testDir)) {
|
|
fs.mkdirSync(testDir, { recursive: true });
|
|
}
|
|
|
|
// Create a test file to work with
|
|
const testFile = path.join(testDir, 'test_video.mp4');
|
|
fs.writeFileSync(testFile, 'test content');
|
|
|
|
console.log('Created test directory and file:', testDir);
|
|
|
|
// Test writing to audit file
|
|
const auditFile = path.join(testDir, '.audit');
|
|
const testEntry = {
|
|
timestamp: new Date().toISOString(),
|
|
action: 'select_directory',
|
|
details: { directory: testDir }
|
|
};
|
|
|
|
try {
|
|
fs.appendFileSync(auditFile, JSON.stringify(testEntry) + '\n');
|
|
console.log('Successfully wrote to audit file:', auditFile);
|
|
|
|
// Read the file back to verify content
|
|
const content = fs.readFileSync(auditFile, 'utf8');
|
|
console.log('Audit file content:');
|
|
console.log(content);
|
|
|
|
console.log('✓ Audit functionality test passed');
|
|
} catch (error) {
|
|
console.error('✗ Audit functionality test failed:', error.message);
|
|
}
|
|
|
|
console.log('Test complete.'); |