summaryrefslogtreecommitdiffstats
path: root/internal/transporthealth/monitor_test.go
diff options
context:
space:
mode:
authorGab Virebent <gabriel1@virebent.art>2026-08-24 17:34:45 +0200
committerGab Virebent <gabriel1@virebent.art>2026-08-24 17:34:45 +0200
commite9fbbe3373eb66a345f5e3829e2563b94dc92051 (patch)
tree950d75fda88574afb46b4aeab36e96f3c089a3bb /internal/transporthealth/monitor_test.go
parentfb83c4d70616ec23d8a5397409a5d31c70b70d66 (diff)
downloadn2usenet-main.tar.gz
n2usenet-main.tar.xz
n2usenet-main.zip
Harden transport and preserve profile identitiesHEADmain
Diffstat (limited to 'internal/transporthealth/monitor_test.go')
-rw-r--r--internal/transporthealth/monitor_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/internal/transporthealth/monitor_test.go b/internal/transporthealth/monitor_test.go
new file mode 100644
index 0000000..c5eb98d
--- /dev/null
+++ b/internal/transporthealth/monitor_test.go
@@ -0,0 +1,30 @@
+package transporthealth
+
+import (
+ "context"
+ "errors"
+ "testing"
+ "time"
+)
+
+type checkerFunc func(context.Context) error
+
+func (f checkerFunc) Check(ctx context.Context) error {
+ return f(ctx)
+}
+
+func TestProbeTracksReadiness(t *testing.T) {
+ var checkErr error
+ monitor := New(checkerFunc(func(context.Context) error { return checkErr }), time.Minute, time.Second)
+
+ monitor.Probe(context.Background())
+ if !monitor.Ready() {
+ t.Fatal("successful probe did not mark transport ready")
+ }
+
+ checkErr = errors.New("transport unavailable")
+ monitor.Probe(context.Background())
+ if monitor.Ready() {
+ t.Fatal("failed probe left transport ready")
+ }
+}