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

Function TestRun_SingleItemOK

internal/eval/eval_test.go:45–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

43}
44
45func TestRun_SingleItemOK(t *testing.T) {
46 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
47 if r.URL.Path != "/infer" || r.Method != http.MethodPost {
48 http.NotFound(w, r)
49 return
50 }
51 w.Header().Set("Content-Type", "application/json")
52 _ = json.NewEncoder(w).Encode(map[string]any{
53 "selected_backend": "small-model",
54 "fallback": map[string]any{"triggered": false},
55 })
56 }))
57 t.Cleanup(srv.Close)
58
59 dir := t.TempDir()
60 path := filepath.Join(dir, "dataset.json")
61 raw := `[{"tenant_id":"team-a","task_type":"chat","input":{"text":"hi"},"options":{"stream":false,"max_tokens":64}}]`
62 if err := os.WriteFile(path, []byte(raw), 0o600); err != nil {
63 t.Fatal(err)
64 }
65 var buf bytes.Buffer
66 err := Run(context.Background(), srv.URL, path, &buf, "inference/basic:v1", "")
67 if err != nil {
68 t.Fatalf("Run: %v", err)
69 }
70 out := buf.String()
71 if !strings.Contains(out, "summary:") || !strings.Contains(out, "items=1") {
72 t.Fatalf("unexpected output:\n%s", out)
73 }
74}

Callers

nothing calls this directly

Calls 1

RunFunction · 0.85

Tested by

no test coverage detected