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") } }