MCPcopy Create free account
hub / github.com/InferCore/InferCore / TestInfer_Success200

Function TestInfer_Success200

internal/server/server_test.go:431–468  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

429}
430
431func TestInfer_Success200(t *testing.T) {
432 srv := New(testConfig(100, true))
433 ts := httptest.NewServer(srv.Routes())
434 defer ts.Close()
435
436 status, body := postInfer(t, ts.URL, map[string]any{
437 "tenant_id": "team-a",
438 "task_type": "simple",
439 "input": map[string]any{
440 "text": "hello",
441 },
442 "options": map[string]any{
443 "stream": false,
444 "max_tokens": 128,
445 },
446 })
447
448 if status != http.StatusOK {
449 t.Fatalf("expected 200, got %d body=%s", status, string(body))
450 }
451
452 var parsed map[string]any
453 if err := json.Unmarshal(body, &parsed); err != nil {
454 t.Fatalf("response must be valid json: %v", err)
455 }
456 if _, ok := parsed["policy_reason"]; !ok {
457 t.Fatalf("missing policy_reason")
458 }
459 if _, ok := parsed["effective_priority"]; !ok {
460 t.Fatalf("missing effective_priority")
461 }
462 if _, ok := parsed["trace_id"]; !ok {
463 t.Fatalf("missing trace_id")
464 }
465 if _, ok := parsed["degrade"]; !ok {
466 t.Fatalf("missing degrade state")
467 }
468}
469
470func TestInfer_PolicyRejected429(t *testing.T) {
471 srv := New(testConfig(100, true))

Callers

nothing calls this directly

Calls 5

postInferFunction · 0.85
RoutesMethod · 0.80
NewFunction · 0.70
testConfigFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected