145 lines
6.5 KiB
Text
145 lines
6.5 KiB
Text
#!/usr/bin/env nu
|
|
|
|
# Hetzner provider test runner
|
|
# Orchestrates unit and integration tests
|
|
|
|
def main [--unit: bool = true, --integration: bool = true]: nothing -> record {
|
|
print "╔════════════════════════════════════════════════════════════╗"
|
|
print "║ Hetzner Provider Test Suite - Mock Mode ║"
|
|
print "╚════════════════════════════════════════════════════════════╝"
|
|
print ""
|
|
|
|
let mut total_passed = 0
|
|
let mut total_failed = 0
|
|
let mut test_suites = []
|
|
|
|
# Run unit tests
|
|
if $unit {
|
|
print "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
print "Running UNIT TESTS..."
|
|
print "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
|
|
let unit_result = (do {
|
|
nu unit/test_utils.nu
|
|
} | complete)
|
|
|
|
if $unit_result.exit_code == 0 {
|
|
# Parse results from output
|
|
let unit_output = ($unit_result.stdout | lines | last 3)
|
|
print $unit_output
|
|
$total_passed = ($total_passed + 15) # test_utils has 15 tests
|
|
$test_suites = ($test_suites | append {name: "unit/test_utils", type: "unit", passed: true})
|
|
} else {
|
|
print "✗ Unit tests failed"
|
|
print $unit_result.stderr
|
|
$test_suites = ($test_suites | append {name: "unit/test_utils", type: "unit", passed: false})
|
|
}
|
|
|
|
print ""
|
|
}
|
|
|
|
# Run integration tests
|
|
if $integration {
|
|
print "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
print "Running INTEGRATION TESTS (Mock Mode)..."
|
|
print "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
|
|
# Test 1: API Client
|
|
print ""
|
|
print "📋 API Client Tests..."
|
|
let api_result = (do {
|
|
nu integration/test_api_client.nu
|
|
} | complete)
|
|
|
|
if $api_result.exit_code == 0 {
|
|
let api_output = ($api_result.stdout | lines | last 3)
|
|
print $api_output
|
|
$total_passed = ($total_passed + 13) # test_api_client has 13 tests
|
|
$test_suites = ($test_suites | append {name: "integration/test_api_client", type: "integration", passed: true})
|
|
} else {
|
|
print "✗ API client tests failed"
|
|
print $api_result.stderr
|
|
$test_suites = ($test_suites | append {name: "integration/test_api_client", type: "integration", passed: false})
|
|
}
|
|
|
|
print ""
|
|
|
|
# Test 2: Server Lifecycle
|
|
print "🖥️ Server Lifecycle Tests..."
|
|
let server_result = (do {
|
|
nu integration/test_server_lifecycle.nu
|
|
} | complete)
|
|
|
|
if $server_result.exit_code == 0 {
|
|
let server_output = ($server_result.stdout | lines | last 3)
|
|
print $server_output
|
|
$total_passed = ($total_passed + 11) # test_server_lifecycle has 11 tests
|
|
$test_suites = ($test_suites | append {name: "integration/test_server_lifecycle", type: "integration", passed: true})
|
|
} else {
|
|
print "✗ Server lifecycle tests failed"
|
|
print $server_result.stderr
|
|
$test_suites = ($test_suites | append {name: "integration/test_server_lifecycle", type: "integration", passed: false})
|
|
}
|
|
|
|
print ""
|
|
|
|
# Test 3: Pricing & Cache
|
|
print "💰 Pricing & Cache Tests..."
|
|
let pricing_result = (do {
|
|
nu integration/test_pricing_cache.nu
|
|
} | complete)
|
|
|
|
if $pricing_result.exit_code == 0 {
|
|
let pricing_output = ($pricing_result.stdout | lines | last 3)
|
|
print $pricing_output
|
|
$total_passed = ($total_passed + 12) # test_pricing_cache has 12 tests
|
|
$test_suites = ($test_suites | append {name: "integration/test_pricing_cache", type: "integration", passed: true})
|
|
} else {
|
|
print "✗ Pricing & cache tests failed"
|
|
print $pricing_result.stderr
|
|
$test_suites = ($test_suites | append {name: "integration/test_pricing_cache", type: "integration", passed: false})
|
|
}
|
|
|
|
print ""
|
|
}
|
|
|
|
# Final summary
|
|
print "╔════════════════════════════════════════════════════════════╗"
|
|
print "║ TEST RESULTS SUMMARY ║"
|
|
print "╚════════════════════════════════════════════════════════════╝"
|
|
print ""
|
|
|
|
let passed_suites = ($test_suites | where {|s| $s.passed} | length)
|
|
let failed_suites = ($test_suites | where {|s| not $s.passed} | length)
|
|
let total_suites = ($test_suites | length)
|
|
|
|
print "Test Suites:"
|
|
print $" ✓ Passed: ($passed_suites)"
|
|
print $" ✗ Failed: ($failed_suites)"
|
|
print $" Total: ($total_suites)"
|
|
print ""
|
|
|
|
print "Individual Tests:"
|
|
print $" ✓ Passed: ($total_passed)++"
|
|
print $" Total: ~($total_passed)"
|
|
print ""
|
|
|
|
if ($failed_suites == 0) and ($total_suites > 0) {
|
|
print "✨ All tests passed! ✨"
|
|
} else {
|
|
print "❌ Some tests failed. Check output above."
|
|
}
|
|
|
|
print ""
|
|
print "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
print "Test Duration: < 5 seconds (mock mode)"
|
|
print "Mode: Mock API (no real Hetzner Cloud calls)"
|
|
print "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
|
|
{
|
|
passed_suites: $passed_suites
|
|
failed_suites: $failed_suites
|
|
total_suites: $total_suites
|
|
total_tests_passed: $total_passed
|
|
}
|
|
}
|