# MARS-828 Test Execution Script
# Purpose: Run rollback and installation tests
# Author: Grzegorz Michalski
# Date: 2026-01-29

Write-Host "`n========================================" -ForegroundColor Cyan
Write-Host "MARS-828 Testing Suite" -ForegroundColor Cyan
Write-Host "========================================`n" -ForegroundColor Cyan

$connectionString = "ADMIN/Cloudpass#34@ggmichalski_high"
$marsFolder = Split-Path -Parent $PSScriptRoot

Write-Host "Test 1: Rollback to v2.0.0" -ForegroundColor Yellow
Write-Host "========================================" -ForegroundColor Yellow
$rollbackCmd = "cd '$marsFolder'; sql '$connectionString' '@rollback_mars828.sql'"
Write-Host "Command: $rollbackCmd`n" -ForegroundColor Gray
Invoke-Expression $rollbackCmd

Write-Host "`nWaiting 5 seconds before installation...`n" -ForegroundColor Gray
Start-Sleep -Seconds 5

Write-Host "Test 2: Installation v3.0.0 (Auto Mode)" -ForegroundColor Yellow
Write-Host "========================================" -ForegroundColor Yellow
$installCmd = "cd '$PSScriptRoot'; sql '$connectionString' '@auto_install.sql'"
Write-Host "Command: $installCmd`n" -ForegroundColor Gray
Invoke-Expression $installCmd

Write-Host "`nWaiting 5 seconds before verification...`n" -ForegroundColor Gray
Start-Sleep -Seconds 5

Write-Host "Test 3: Final Summary" -ForegroundColor Yellow
Write-Host "========================================" -ForegroundColor Yellow
$summaryCmd = "cd '$PSScriptRoot'; sql 'CT_MRDS/$connectionString' '@final_summary.sql'"
Write-Host "Command: $summaryCmd`n" -ForegroundColor Gray
Invoke-Expression $summaryCmd

Write-Host "`n========================================" -ForegroundColor Green
Write-Host "MARS-828 Testing Complete" -ForegroundColor Green
Write-Host "========================================`n" -ForegroundColor Green
Write-Host "Check log files in: $marsFolder\log\" -ForegroundColor Cyan
