49 lines
1.7 KiB
JavaScript
49 lines
1.7 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { extractJobIdFromFileName } = require('./helpers/satloc_util');
|
|
|
|
// Test fallback behavior by simulating a file without JOB prefix
|
|
console.log('=== Job ID Fallback Logic Test ===\n');
|
|
|
|
async function testFallbackLogic() {
|
|
// Test cases to show fallback logic
|
|
const testCases = [
|
|
{
|
|
fileName: 'JOB146 HK4704.log',
|
|
description: 'Filename with JOB prefix (primary source)'
|
|
},
|
|
{
|
|
fileName: 'RandomFileName.log',
|
|
description: 'Filename without recognizable pattern (fallback to record)'
|
|
},
|
|
{
|
|
fileName: '2507140724SatlocG4_b4ef.log',
|
|
description: 'Falcon system filename (primary source)'
|
|
}
|
|
];
|
|
|
|
for (const testCase of testCases) {
|
|
console.log(`--- ${testCase.description} ---`);
|
|
console.log(`Filename: ${testCase.fileName}`);
|
|
|
|
const filenameJobId = extractJobIdFromFileName(testCase.fileName);
|
|
console.log(`Filename extraction: ${filenameJobId || 'Not found'}`);
|
|
|
|
// Simulate what would happen in createApplicationDetail
|
|
const mockJobLongLabelName = 'CALIMA_FIELD_01'; // From Swathing Setup (120)
|
|
const mockSwathingJobId = '999'; // Numeric ID from Swathing Setup (120)
|
|
|
|
// Apply the fallback logic (filename primary, jobLongLabelName fallback)
|
|
const satlocJobId = filenameJobId || mockJobLongLabelName;
|
|
|
|
console.log(`Fallback jobLongLabelName: ${mockJobLongLabelName}`);
|
|
console.log(`Fallback swathingJobId: ${mockSwathingJobId}`);
|
|
console.log(`Final satlocJobId: ${satlocJobId}`);
|
|
console.log(`Source: ${filenameJobId ? 'filename' : 'jobLongLabelName fallback'}`);
|
|
console.log('');
|
|
}
|
|
}
|
|
|
|
testFallbackLogic().catch(console.error); |