diff options
| author | Gab Virebent <gabriel1@virebent.art> | 2026-08-24 17:34:45 +0200 |
|---|---|---|
| committer | Gab Virebent <gabriel1@virebent.art> | 2026-08-24 17:34:45 +0200 |
| commit | e9fbbe3373eb66a345f5e3829e2563b94dc92051 (patch) | |
| tree | 950d75fda88574afb46b4aeab36e96f3c089a3bb /internal/transporthealth/monitor_test.go | |
| parent | fb83c4d70616ec23d8a5397409a5d31c70b70d66 (diff) | |
| download | n2usenet-e9fbbe3373eb66a345f5e3829e2563b94dc92051.tar.gz n2usenet-e9fbbe3373eb66a345f5e3829e2563b94dc92051.tar.xz n2usenet-e9fbbe3373eb66a345f5e3829e2563b94dc92051.zip | |
Diffstat (limited to 'internal/transporthealth/monitor_test.go')
| -rw-r--r-- | internal/transporthealth/monitor_test.go | 30 |
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") + } +} |
