TestRunBatchConcurrent 测试并发批量评估
(t *testing.T)
| 85 | |
| 86 | // TestRunBatchConcurrent 测试并发批量评估 |
| 87 | func TestRunBatchConcurrent(t *testing.T) { |
| 88 | mockProvider := &MockProvider{ |
| 89 | response: `{"score": 0.90, "reason": "并发测试"}`, |
| 90 | } |
| 91 | |
| 92 | // 创建多个测试用例 |
| 93 | testCases := make([]*BatchTestCase, 10) |
| 94 | for i := range 10 { |
| 95 | testCases[i] = &BatchTestCase{ |
| 96 | ID: string(rune('A' + i)), |
| 97 | Input: &TextEvalInput{ |
| 98 | Answer: "测试答案", |
| 99 | }, |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | scorers := []Scorer{ |
| 104 | NewFaithfulnessScorer(mockProvider), |
| 105 | NewHallucinationScorer(mockProvider), |
| 106 | } |
| 107 | |
| 108 | // 测试并发度为 3 |
| 109 | result, err := RunBatchConcurrent(context.Background(), testCases, scorers, 3) |
| 110 | if err != nil { |
| 111 | t.Fatalf("RunBatchConcurrent() error = %v", err) |
| 112 | } |
| 113 | |
| 114 | if len(result.Results) != 10 { |
| 115 | t.Errorf("RunBatchConcurrent() got %d results, want 10", len(result.Results)) |
| 116 | } |
| 117 | |
| 118 | if result.Summary.SuccessfulCases != 10 { |
| 119 | t.Errorf("RunBatchConcurrent() SuccessfulCases = %d, want 10", result.Summary.SuccessfulCases) |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | // TestRunBatch_ProgressCallback 测试进度回调 |
| 124 | func TestRunBatch_ProgressCallback(t *testing.T) { |
nothing calls this directly
no test coverage detected