package agentd import "testing" // TestClashHealthSource_Debounce verifies the 2-strike debounce: a single failed // probe is tolerated (sing-box restart window), two consecutive failures report // unhealthy, and a success resets the strike counter. func TestClashHealthSource_Debounce(t *testing.T) { probeResults := []bool{true, false, false, false, true, false} want := []bool{true, true, false, false, true, true} // ↑ok ↑1st ↑2nd ↑3rd ↑ok ↑1st-after-reset i := 0 h := &clashHealthSource{probe: func() bool { r := probeResults[i] i++ return r }} for n, w := range want { if got := h.Healthy(); got != w { t.Errorf("Healthy() call %d = %v, want %v (probe=%v)", n, got, w, probeResults[n]) } } }