MCPcopy Create free account
hub / github.com/astercloud/aster / TestRunBatch_WithMetadata

Function TestRunBatch_WithMetadata

pkg/evals/batch_test.go:241–276  ·  view source on GitHub ↗

TestRunBatch_WithMetadata 测试带元数据的批量评估

(t *testing.T)

Source from the content-addressed store, hash-verified

239
240// TestRunBatch_WithMetadata 测试带元数据的批量评估
241func TestRunBatch_WithMetadata(t *testing.T) {
242 mockProvider := &MockProvider{
243 response: `{"score": 0.80, "reason": "元数据测试"}`,
244 }
245
246 testCases := []*BatchTestCase{
247 {
248 ID: "case1",
249 Input: &TextEvalInput{
250 Answer: "测试答案",
251 },
252 Metadata: map[string]any{
253 "source": "test",
254 "priority": 1,
255 },
256 },
257 }
258
259 scorers := []Scorer{
260 NewFaithfulnessScorer(mockProvider),
261 }
262
263 result, err := RunBatchSimple(context.Background(), testCases, scorers)
264 if err != nil {
265 t.Fatalf("RunBatchSimple() error = %v", err)
266 }
267
268 // 验证元数据被保留
269 if result.Results[0].Metadata == nil {
270 t.Error("Result metadata is nil")
271 }
272
273 if result.Results[0].Metadata["source"] != "test" {
274 t.Errorf("Metadata source = %v, want test", result.Results[0].Metadata["source"])
275 }
276}
277
278// TestCalculateSummary 测试汇总计算
279func TestCalculateSummary(t *testing.T) {

Callers

nothing calls this directly

Calls 3

NewFaithfulnessScorerFunction · 0.85
RunBatchSimpleFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected