import { createHetznerClient } from './api/hetzner';
import { createDokployClient } from './api/dokploy';

async function testHetznerClient() {
  console.log('\n🔍 Testing Hetzner DNS Client...');
  
  try {
    const client = createHetznerClient();
    const result = await client.testConnection();
    
    if (result.success) {
      console.log(`✅ Hetzner: ${result.message}`);
      return true;
    } else {
      console.log(`❌ Hetzner: ${result.message}`);
      return false;
    }
  } catch (error) {
    console.log(`❌ Hetzner: ${error instanceof Error ? error.message : 'Unknown error'}`);
    return false;
  }
}

async function testDokployClient() {
  console.log('\n🔍 Testing Dokploy Client...');
  
  try {
    const client = createDokployClient();
    const result = await client.testConnection();
    
    if (result.success) {
      console.log(`✅ Dokploy: ${result.message}`);
      return true;
    } else {
      console.log(`❌ Dokploy: ${result.message}`);
      return false;
    }
  } catch (error) {
    console.log(`❌ Dokploy: ${error instanceof Error ? error.message : 'Unknown error'}`);
    return false;
  }
}

async function main() {
  console.log('═══════════════════════════════════════');
  console.log('  AI Stack Deployer - API Client Tests');
  console.log('═══════════════════════════════════════');
  
  const hetznerOk = await testHetznerClient();
  const dokployOk = await testDokployClient();
  
  console.log('\n═══════════════════════════════════════');
  console.log('  Test Summary');
  console.log('═══════════════════════════════════════');
  console.log(`Hetzner DNS: ${hetznerOk ? '✅ PASS' : '❌ FAIL'}`);
  console.log(`Dokploy API: ${dokployOk ? '✅ PASS' : '❌ FAIL'}`);
  console.log('═══════════════════════════════════════\n');
  
  if (!hetznerOk || !dokployOk) {
    process.exit(1);
  }
}

main();
