MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestReachableHitsV1Models

Function TestReachableHitsV1Models

internal/cloud/cloud_test.go:14–30  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

12// OpenAI-standard listing endpoint every backend serves. Probing GET /
13// instead could block behind a backend's inference loop until timeout.
14func 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.

Callers

nothing calls this directly

Calls 1

ReachableFunction · 0.85

Tested by

no test coverage detected