TestReachableHitsV1Models pins the heartbeat path: /v1/models, the OpenAI-standard listing endpoint every backend serves. Probing GET / instead could block behind a backend's inference loop until timeout.
(t *testing.T)
| 12 | // OpenAI-standard listing endpoint every backend serves. Probing GET / |
| 13 | // instead could block behind a backend's inference loop until timeout. |
| 14 | func TestReachableHitsV1Models(t *testing.T) { |
| 15 | var gotPath string |
| 16 | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 17 | gotPath = r.URL.Path |
| 18 | w.WriteHeader(http.StatusOK) |
| 19 | })) |
| 20 | defer srv.Close() |
| 21 | |
| 22 | ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) |
| 23 | defer cancel() |
| 24 | if err := Reachable(ctx, srv.URL); err != nil { |
| 25 | t.Fatalf("Reachable returned %v, want nil", err) |
| 26 | } |
| 27 | if gotPath != "/v1/models" { |
| 28 | t.Fatalf("Reachable hit %q, want /v1/models", gotPath) |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | // TestReachableTreatsNon2xxAsReachable: any HTTP response counts as |
| 33 | // reachable (even 404/401); only transport errors and timeouts mean down. |
nothing calls this directly
no test coverage detected