test-update-view-source.jsā¢1.8 kB
/**
* Test script for UpdateViewSource tool
* Tests updating DDL source code of existing CDS/Classic Views
*/
const {
initializeTestEnvironment,
getAllEnabledTestCases,
printTestHeader,
printTestParams,
printTestResult
} = require('./test-helper');
// Initialize test environment
initializeTestEnvironment();
const { handleUpdateViewSource } = require('../dist/handlers/handleUpdateViewSource');
async function testUpdateViewSource() {
const testCases = getAllEnabledTestCases('update_view_source');
console.log(`\nš Found ${testCases.length} enabled test case(s)\n`);
let passedTests = 0;
let failedTests = 0;
for (const testCase of testCases) {
printTestHeader('UpdateViewSource', testCase);
const params = testCase.params;
printTestParams(params);
console.log('--- Starting view source update flow ---\n');
try {
const result = await handleUpdateViewSource(params);
if (printTestResult(result, 'UpdateViewSource')) {
passedTests++;
} else {
failedTests++;
}
} catch (error) {
console.error('ā Unexpected error during view source update:');
console.error(error);
failedTests++;
}
console.log('\n' + '='.repeat(60) + '\\n');
}
console.log(`\nš Test Summary:`);
console.log(` ā
Passed: ${passedTests}`);
console.log(` ā Failed: ${failedTests}`);
console.log(` š Total: ${testCases.length}`);
if (failedTests > 0) {
process.exit(1);
}
}
// Run the test
testUpdateViewSource()
.then(() => {
console.log('\n=== All tests completed successfully ===');
process.exit(0);
})
.catch(error => {
console.error('\n=== Tests failed ===');
console.error(error);
process.exit(1);
});