MCPcopy
hub / github.com/OpenNHP/opennhp / TestRouting_NoInstanceReturns503

Function TestRouting_NoInstanceReturns503

endpoints/relay/routing_test.go:183–193  ·  view source on GitHub ↗

TestRouting_NoInstanceReturns503 exercises the phase-2-future safety guard: a configured cluster with zero usable instances must return 503, not panic on a nil pickInstance().

(t *testing.T)

Source from the content-addressed store, hash-verified

181// guard: a configured cluster with zero usable instances must return 503,
182// not panic on a nil pickInstance().
183func TestRouting_NoInstanceReturns503(t *testing.T) {
184 rs := newRoutingTestServer("good-id")
185
186 w := httptest.NewRecorder()
187 rs.handleRelay(w, newRelayRequest(http.MethodPost, "/relay/good-id", validInnerPacket))
188
189 if w.Code != http.StatusServiceUnavailable {
190 t.Fatalf("expected 503 when cluster has no instance, got %d (body: %s)",
191 w.Code, w.Body.String())
192 }
193}
194
195// TestRouting_TrailingSlashTolerated: POST /relay/<id>/ should resolve the
196// same as POST /relay/<id>. Some HTTP clients and proxies normalize paths

Callers

nothing calls this directly

Calls 4

newRoutingTestServerFunction · 0.85
newRelayRequestFunction · 0.85
handleRelayMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected