Initial commit: stats-gateway gRPC service + dashboard + CLI
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user