UNPKG

agentic-data-stack-community

Version:

AI Agentic Data Stack Framework - Community Edition. Open source data engineering framework with 4 core agents, essential templates, and 3-dimensional quality validation.

154 lines (134 loc) 5.72 kB
const { execSync } = require('child_process'); const path = require('path'); const fs = require('fs-extra'); // Path to CLI const CLI_PATH = path.join(__dirname, '../tools/cli.js'); // Helper function to run CLI commands function runCLI(args) { try { const output = execSync(`node ${CLI_PATH} ${args}`, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }); return { success: true, output }; } catch (error) { // Combine stdout and stderr for error cases const output = (error.stdout || '') + (error.stderr || '') + (error.message || ''); return { success: false, output, error }; } } describe('AI Agentic Data Stack CLI Tests', () => { // Create test directories before tests beforeAll(async () => { await fs.ensureDir(path.join(__dirname, '../agents')); await fs.ensureDir(path.join(__dirname, '../templates/analytics')); await fs.ensureDir(path.join(__dirname, '../templates/engineering')); await fs.ensureDir(path.join(__dirname, '../templates/quality')); // Copy test files from testapp if they exist const testappPath = path.join(__dirname, '../testapp'); if (await fs.pathExists(testappPath)) { await fs.copy(path.join(testappPath, 'agents'), path.join(__dirname, '../agents')); await fs.copy(path.join(testappPath, 'templates'), path.join(__dirname, '../templates')); } }); describe('Basic Commands', () => { test('should display version', () => { const result = runCLI('--version'); expect(result.success).toBe(true); expect(result.output).toMatch(/1\.0\.1/); }); test('should display help', () => { const result = runCLI('--help'); expect(result.success).toBe(true); expect(result.output).toContain('AI Agentic Data Stack Framework'); expect(result.output).toContain('Commands:'); }); test('should run info command', () => { const result = runCLI('info'); expect(result.success).toBe(true); expect(result.output).toContain('AI Agentic Data Stack Framework - Community Edition'); expect(result.output).toContain('4 Core AI Agents'); expect(result.output).toContain('20 Essential Templates'); }); }); describe('Agent Commands', () => { test('should list agents', () => { const result = runCLI('agents list'); expect(result.success).toBe(true); expect(result.output).toContain('Available AI Agents'); expect(result.output).toContain('Data Engineer'); expect(result.output).toContain('Data Analyst'); expect(result.output).toContain('Data Product Manager'); expect(result.output).toContain('Data Quality Engineer'); }); test('should show agent details', () => { const result = runCLI('agents show data-engineer'); expect(result.success).toBe(true); expect(result.output).toContain('Data Engineer'); expect(result.output).toContain('Core Capabilities:'); expect(result.output).toContain('Key Deliverables:'); }); test('should handle non-existent agent', () => { const result = runCLI('agents show non-existent-agent'); expect(result.success).toBe(false); expect(result.output).toContain('not found'); }); }); describe('Template Commands', () => { test('should list templates', () => { const result = runCLI('templates list'); expect(result.success).toBe(true); expect(result.output).toContain('Available Templates'); expect(result.output).toContain('ANALYTICS'); expect(result.output).toContain('ENGINEERING'); expect(result.output).toContain('QUALITY'); }); test('should show template details', () => { const result = runCLI('templates show customer-segmentation'); expect(result.success).toBe(true); expect(result.output).toContain('Customer Segmentation'); expect(result.output).toContain('Deliverables:'); expect(result.output).toContain('Use Cases:'); }); }); describe('Example Commands', () => { test('should list examples', () => { const result = runCLI('examples list'); expect(result.success).toBe(true); expect(result.output).toContain('Available Examples'); expect(result.output).toContain('simple-ecommerce-analytics'); }); }); describe('Validation Command', () => { test('should run validation command', () => { const result = runCLI('validate --path .'); // This might fail if Python is not installed, but should not crash expect(result.output).toBeDefined(); }); }); describe('Error Handling', () => { test('should handle invalid commands', () => { const result = runCLI('invalid-command'); expect(result.success).toBe(false); // Check for the actual output format expect(result.output).toContain('See --help for a list of available commands'); }); test('should handle missing arguments', () => { const result = runCLI('agents show'); expect(result.success).toBe(false); expect(result.output).toContain('missing required argument'); }); }); }); // Integration test for init command (optional, requires user interaction) describe('Init Command (Manual Test)', () => { test.skip('should initialize a new project', async () => { const testProjectPath = path.join(__dirname, '../test-project'); // Clean up any existing test project await fs.remove(testProjectPath); console.log('Manual test: Run the following command and follow prompts:'); console.log(`node ${CLI_PATH} init -n test-project`); // After manual execution, verify project structure // expect(await fs.pathExists(testProjectPath)).toBe(true); }); });