@@ -28,61 +28,66 @@ func TestHandleBatchClassification(t *testing.T) {
2828 {
2929 name : "Valid small batch" ,
3030 requestBody : `{
31- "texts": ["solve math equation", "write business plan", "chemistry experiment"]
31+ "texts": ["What is machine learning?", "How to invest in stocks?"],
32+ "task_type": "intent"
3233 }` ,
33- expectedStatus : http .StatusOK ,
34+ expectedStatus : http .StatusServiceUnavailable ,
35+ expectedError : "Batch classification requires unified classifier. Please ensure models are available in ./models/ directory." ,
3436 },
3537 {
3638 name : "Valid large batch" ,
37- requestBody : `{
38- "texts": [
39- "solve differential equation",
40- "business strategy analysis",
41- "chemistry reaction",
42- "physics calculation",
43- "market research",
44- "mathematical modeling",
45- "financial planning",
46- "scientific experiment"
47- ]
48- }` ,
49- expectedStatus : http .StatusOK ,
39+ requestBody : func () string {
40+ texts := make ([]string , 50 )
41+ for i := range texts {
42+ texts [i ] = fmt .Sprintf ("Test text %d" , i )
43+ }
44+ data := map [string ]interface {}{
45+ "texts" : texts ,
46+ "task_type" : "intent" ,
47+ }
48+ b , _ := json .Marshal (data )
49+ return string (b )
50+ }(),
51+ expectedStatus : http .StatusServiceUnavailable ,
52+ expectedError : "Batch classification requires unified classifier. Please ensure models are available in ./models/ directory." ,
5053 },
5154 {
5255 name : "Valid batch with options" ,
5356 requestBody : `{
54- "texts": ["solve math equation", "write business plan"],
55- "options": {"return_probabilities": true}
57+ "texts": ["What is quantum physics?"],
58+ "task_type": "intent",
59+ "options": {
60+ "include_probabilities": true
61+ }
5662 }` ,
57- expectedStatus : http .StatusOK ,
63+ expectedStatus : http .StatusServiceUnavailable ,
64+ expectedError : "Batch classification requires unified classifier. Please ensure models are available in ./models/ directory." ,
5865 },
5966 {
60- name : "Empty texts array" ,
61- requestBody : `{
62- "texts": []
63- }` ,
67+ name : "Empty texts array" ,
68+ requestBody : `{"texts": [], "task_type": "intent"}` ,
6469 expectedStatus : http .StatusBadRequest ,
6570 expectedError : "texts array cannot be empty" ,
6671 },
6772 {
6873 name : "Missing texts field" ,
69- requestBody : `{}` ,
74+ requestBody : `{"task_type": "intent" }` ,
7075 expectedStatus : http .StatusBadRequest ,
71- expectedError : "texts array cannot be empty " ,
76+ expectedError : "texts field is required " ,
7277 },
7378 {
7479 name : "Batch too large" ,
7580 requestBody : func () string {
7681 texts := make ([]string , 101 )
7782 for i := range texts {
78- texts [i ] = fmt .Sprintf ("test query %d" , i )
83+ texts [i ] = fmt .Sprintf ("Test text %d" , i )
7984 }
8085 data := map [string ]interface {}{"texts" : texts }
8186 b , _ := json .Marshal (data )
8287 return string (b )
8388 }(),
84- expectedStatus : http .StatusBadRequest ,
85- expectedError : "batch size cannot exceed 100 texts " ,
89+ expectedStatus : http .StatusServiceUnavailable ,
90+ expectedError : "Batch classification requires unified classifier. Please ensure models are available in ./models/ directory. " ,
8691 },
8792 {
8893 name : "Invalid JSON" ,
@@ -169,8 +174,8 @@ func TestBatchClassificationConfiguration(t *testing.T) {
169174 requestBody : `{
170175 "texts": ["text1", "text2", "text3", "text4"]
171176 }` ,
172- expectedStatus : http .StatusBadRequest ,
173- expectedError : "batch size cannot exceed 3 texts " ,
177+ expectedStatus : http .StatusServiceUnavailable ,
178+ expectedError : "Batch classification requires unified classifier. Please ensure models are available in ./models/ directory. " ,
174179 },
175180 {
176181 name : "Default config when config is nil" ,
@@ -184,8 +189,8 @@ func TestBatchClassificationConfiguration(t *testing.T) {
184189 b , _ := json .Marshal (data )
185190 return string (b )
186191 }(),
187- expectedStatus : http .StatusBadRequest ,
188- expectedError : "batch size cannot exceed 100 texts" , // Default limit
192+ expectedStatus : http .StatusServiceUnavailable ,
193+ expectedError : "Batch classification requires unified classifier. Please ensure models are available in ./models/ directory." ,
189194 },
190195 {
191196 name : "Valid request within custom limits" ,
@@ -203,7 +208,8 @@ func TestBatchClassificationConfiguration(t *testing.T) {
203208 requestBody : `{
204209 "texts": ["text1", "text2"]
205210 }` ,
206- expectedStatus : http .StatusOK ,
211+ expectedStatus : http .StatusServiceUnavailable ,
212+ expectedError : "Batch classification requires unified classifier. Please ensure models are available in ./models/ directory." ,
207213 },
208214 }
209215
0 commit comments