(t *testing.T)
| 429 | } |
| 430 | |
| 431 | func 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 | |
| 470 | func TestInfer_PolicyRejected429(t *testing.T) { |
| 471 | srv := New(testConfig(100, true)) |
nothing calls this directly
no test coverage detected