forked from Soroban-Pulse/SorobanPulse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate_implementation.ps1
More file actions
166 lines (140 loc) · 6.49 KB
/
validate_implementation.ps1
File metadata and controls
166 lines (140 loc) · 6.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Email Notification Feature Validation Script
# This script validates that all required files and changes are in place
Write-Host "=========================================="
Write-Host "Email Notification Feature Validation"
Write-Host "=========================================="
Write-Host ""
$allChecks = @()
$passedChecks = 0
$failedChecks = 0
function Test-FileExists {
param($path, $description)
if (Test-Path $path) {
Write-Host "✅ $description" -ForegroundColor Green
$script:passedChecks++
return $true
} else {
Write-Host "❌ $description" -ForegroundColor Red
$script:failedChecks++
return $false
}
}
function Test-FileContains {
param($path, $pattern, $description)
if (Test-Path $path) {
$content = Get-Content $path -Raw
if ($content -match $pattern) {
Write-Host "✅ $description" -ForegroundColor Green
$script:passedChecks++
return $true
} else {
Write-Host "❌ $description" -ForegroundColor Red
$script:failedChecks++
return $false
}
} else {
Write-Host "❌ $description (file not found)" -ForegroundColor Red
$script:failedChecks++
return $false
}
}
Write-Host "Checking Files..." -ForegroundColor Cyan
Write-Host ""
# Check new files
Test-FileExists "src/email.rs" "Email module created"
Test-FileExists "tests/email_notification_tests.rs" "Email tests created"
Test-FileExists "docs/email-notifications.md" "Email documentation created"
Test-FileExists "docs/email-quick-start.md" "Quick start guide created"
Test-FileExists "IMPLEMENTATION_SUMMARY.md" "Implementation summary created"
Test-FileExists "EMAIL_FEATURE_COMPLETE.md" "Feature completion doc created"
Write-Host ""
Write-Host "Checking Dependencies..." -ForegroundColor Cyan
Write-Host ""
# Check Cargo.toml
Test-FileContains "Cargo.toml" "lettre" "lettre dependency added to Cargo.toml"
Write-Host ""
Write-Host "Checking Configuration..." -ForegroundColor Cyan
Write-Host ""
# Check config.rs
Test-FileContains "src/config.rs" "email_smtp_host" "email_smtp_host field in Config"
Test-FileContains "src/config.rs" "email_smtp_port" "email_smtp_port field in Config"
Test-FileContains "src/config.rs" "email_smtp_user" "email_smtp_user field in Config"
Test-FileContains "src/config.rs" "email_smtp_password" "email_smtp_password field in Config"
Test-FileContains "src/config.rs" "email_from" "email_from field in Config"
Test-FileContains "src/config.rs" "email_to" "email_to field in Config"
Test-FileContains "src/config.rs" "email_contract_filter" "email_contract_filter field in Config"
Write-Host ""
Write-Host "Checking Main Integration..." -ForegroundColor Cyan
Write-Host ""
# Check main.rs
Test-FileContains "src/main.rs" "mod email" "email module imported in main.rs"
Test-FileContains "src/main.rs" "email::EmailNotifier" "EmailNotifier used in main.rs"
Test-FileContains "src/main.rs" "email_smtp_host" "email configuration checked in main.rs"
Write-Host ""
Write-Host "Checking Metrics..." -ForegroundColor Cyan
Write-Host ""
# Check metrics.rs
Test-FileContains "src/metrics.rs" "record_email_failure" "record_email_failure function added"
Test-FileContains "src/metrics.rs" "soroban_pulse_email_failures_total" "email failure metric defined"
Write-Host ""
Write-Host "Checking Module Exports..." -ForegroundColor Cyan
Write-Host ""
# Check lib.rs
Test-FileContains "src/lib.rs" "pub mod email" "email module exported in lib.rs"
Write-Host ""
Write-Host "Checking Documentation..." -ForegroundColor Cyan
Write-Host ""
# Check .env.example
Test-FileContains ".env.example" "EMAIL_SMTP_HOST" "EMAIL_SMTP_HOST documented"
Test-FileContains ".env.example" "EMAIL_SMTP_PORT" "EMAIL_SMTP_PORT documented"
Test-FileContains ".env.example" "EMAIL_SMTP_USER" "EMAIL_SMTP_USER documented"
Test-FileContains ".env.example" "EMAIL_SMTP_PASSWORD" "EMAIL_SMTP_PASSWORD documented"
Test-FileContains ".env.example" "EMAIL_FROM" "EMAIL_FROM documented"
Test-FileContains ".env.example" "EMAIL_TO" "EMAIL_TO documented"
Test-FileContains ".env.example" "EMAIL_CONTRACT_FILTER" "EMAIL_CONTRACT_FILTER documented"
# Check README.md
Test-FileContains "README.md" "Email Notifications" "Email notifications section in README"
Test-FileContains "README.md" "soroban_pulse_email_failures_total" "Email metric in README"
# Check CHANGELOG.md
Test-FileContains "CHANGELOG.md" "Email notification" "Email feature in CHANGELOG"
Write-Host ""
Write-Host "Checking Email Module Implementation..." -ForegroundColor Cyan
Write-Host ""
# Check email.rs implementation
Test-FileContains "src/email.rs" "EmailNotifier" "EmailNotifier struct defined"
Test-FileContains "src/email.rs" "spawn" "spawn method implemented"
Test-FileContains "src/email.rs" "send_batch_email" "send_batch_email method implemented"
Test-FileContains "src/email.rs" "send_email" "send_email method implemented"
Test-FileContains "src/email.rs" "lettre" "lettre crate used"
Test-FileContains "src/email.rs" "SmtpTransport" "SMTP transport configured"
Write-Host ""
Write-Host "Checking Tests..." -ForegroundColor Cyan
Write-Host ""
# Check test file
Test-FileContains "tests/email_notification_tests.rs" "test_email_notifier_filters_by_contract" "Contract filter test"
Test-FileContains "tests/email_notification_tests.rs" "test_email_notifier_accepts_all_when_no_filter" "No filter test"
Test-FileContains "tests/email_notification_tests.rs" "test_email_notifier_handles_channel_close" "Channel close test"
Test-FileContains "tests/email_notification_tests.rs" "test_email_config_parsing" "Config parsing test"
Write-Host ""
Write-Host "=========================================="
Write-Host "Validation Summary"
Write-Host "=========================================="
Write-Host ""
Write-Host "Passed: $passedChecks" -ForegroundColor Green
Write-Host "Failed: $failedChecks" -ForegroundColor Red
Write-Host ""
if ($failedChecks -eq 0) {
Write-Host "🎉 All validation checks passed!" -ForegroundColor Green
Write-Host ""
Write-Host "The email notification feature is fully implemented and ready for testing."
Write-Host ""
Write-Host "Next steps:"
Write-Host "1. Run 'cargo test email' to execute the test suite"
Write-Host "2. Run 'cargo build' to compile the project"
Write-Host "3. Configure email settings in .env"
Write-Host "4. Start the service and verify email notifications"
exit 0
} else {
Write-Host "⚠️ Some validation checks failed. Please review the output above." -ForegroundColor Yellow
exit 1
}