Initial commit: stats-gateway gRPC service + dashboard + CLI

This commit is contained in:
2026-05-05 21:04:32 +05:00
commit 4059e94759
44 changed files with 2513 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
package probes
import (
"context"
"testing"
"time"
)
func TestProbeHTTP_Success(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
r, err := ProbeHTTP(ctx, "https://example.com/")
if err != nil {
t.Fatalf("expected success, got err: %v", err)
}
if r.HTTPLatencyMs <= 0 {
t.Errorf("expected positive latency, got %f", r.HTTPLatencyMs)
}
if r.TLSHandshakeMs <= 0 {
t.Errorf("expected positive TLS handshake time, got %f", r.TLSHandshakeMs)
}
}
func TestProbeHTTP_Timeout(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
defer cancel()
_, err := ProbeHTTP(ctx, "https://10.255.255.1/") // unreachable
if err == nil {
t.Fatal("expected timeout error")
}
}