(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestRun_ItemHTTPNonOK(t *testing.T) { |
| 16 | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 17 | w.WriteHeader(http.StatusBadRequest) |
| 18 | _ = json.NewEncoder(w).Encode(map[string]any{ |
| 19 | "status": "error", |
| 20 | "error": map[string]any{"code": "invalid_request", "message": "bad"}, |
| 21 | }) |
| 22 | })) |
| 23 | t.Cleanup(srv.Close) |
| 24 | |
| 25 | dir := t.TempDir() |
| 26 | path := filepath.Join(dir, "dataset.json") |
| 27 | raw := `[{"tenant_id":"team-a","task_type":"chat","input":{"text":"x"},"options":{"stream":false,"max_tokens":64}}]` |
| 28 | if err := os.WriteFile(path, []byte(raw), 0o600); err != nil { |
| 29 | t.Fatal(err) |
| 30 | } |
| 31 | var buf bytes.Buffer |
| 32 | err := Run(context.Background(), srv.URL, path, &buf, "inference/basic:v1", "") |
| 33 | if err != nil { |
| 34 | t.Fatalf("Run: %v", err) |
| 35 | } |
| 36 | out := buf.String() |
| 37 | if !strings.Contains(out, "ok=false") || !strings.Contains(out, "http=400") { |
| 38 | t.Fatalf("expected non-OK row in output:\n%s", out) |
| 39 | } |
| 40 | if !strings.Contains(out, "summary:") { |
| 41 | t.Fatalf("missing summary:\n%s", out) |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | func TestRun_SingleItemOK(t *testing.T) { |
| 46 | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected