test-workflow-file-adapter.js 1.2 KB

12345678910111213141516171819202122232425
  1. import fs from 'fs/promises';
  2. import os from 'os';
  3. import path from 'path';
  4. import { WorkflowExecutor } from './src/vl/workflow-executor.js';
  5. function assert(condition, message) {
  6. if (!condition) throw new Error(message);
  7. }
  8. console.log('\n── Workflow File Adapter ──');
  9. const workDir = await fs.mkdtemp(path.join(os.tmpdir(), 'vlcode-file-adapter-'));
  10. const executor = new WorkflowExecutor({ workDir, vlVersion: '3.5' });
  11. const file = executor._buildFileAdapter();
  12. await file.write('/Sections/TestSection.sc', '\n\n// VL_VERSION:3.6\n<Section-TestSection>\n', 'overwrite');
  13. const sectionContent = await fs.readFile(path.join(workDir, 'Sections', 'TestSection.sc'), 'utf-8');
  14. assert(sectionContent.startsWith('// VL_VERSION:3.5\n'), 'section file should start with normalized VL_VERSION header');
  15. await file.write('/Services/TestService.vs', 'SERVICE Ping();RETURN STRING\n-RETURN "ok"\n', 'overwrite');
  16. const serviceContent = await fs.readFile(path.join(workDir, 'Services', 'TestService.vs'), 'utf-8');
  17. assert(serviceContent.startsWith('// VL_VERSION:3.5\n'), 'service file should get a missing VL_VERSION header');
  18. console.log('PASS test-workflow-file-adapter.js');