@@ -151,7 +151,37 @@ func TestRuntimeHandler_Handle_InvalidCommand(t *testing.T) {
151151 req := createRequest (http .MethodPost , "/!invalid" , []byte (`{}` ), http.Header {})
152152 resp := handler .Handle (context .Background (), req )
153153
154- require .Equal (t , http .StatusBadRequest , resp .StatusCode )
154+ var respBody map [string ]any
155+ err = json .Unmarshal (resp .Body , & respBody )
156+ require .NoError (t , err )
157+
158+ responseError := respBody ["error" ].(map [string ]interface {})
159+
160+ require .Equal (t , "request validation error" , responseError ["message" ])
161+ }
162+
163+ func TestRuntimeHandler_Handle_Empty_Command (t * testing.T ) {
164+ mockResponse := runtime.EvaluationResponse {
165+ "command" : "eval" ,
166+ "result" : map [string ]interface {}{
167+ "is_correct" : true ,
168+ "feedback" : "Well done! Your answer is correct." ,
169+ },
170+ }
171+
172+ handler := setupHandlerWithStaticMock (t , mockResponse )
173+
174+ body := createRequestBody (t , map [string ]any {
175+ "response" : 1 ,
176+ "answer" : 1 ,
177+ })
178+
179+ req := createRequest (http .MethodPost , "" , body , http.Header {})
180+
181+ resp := handler .Handle (context .Background (), req )
182+ respBody := parseResponseBody (t , resp )
183+
184+ require .Equal (t , mockResponse ["result" ], respBody ["result" ])
155185}
156186
157187func TestRuntimeHandler_Handle_InvalidMethod (t * testing.T ) {
@@ -416,8 +446,8 @@ func TestRunTimeHandler_Healthcheck(t *testing.T) {
416446 handler := setupHandlerWithStaticMock (t , mockResponse )
417447 body := createRequestBody (t , map [string ]any {})
418448
419- req := createRequest (http .MethodPost , "/healthcheck " , body , http.Header {
420- "command " : []string {"healthcheck" },
449+ req := createRequest (http .MethodPost , "/" , body , http.Header {
450+ "Command " : []string {"healthcheck" },
421451 })
422452
423453 resp := handler .Handle (context .Background (), req )
@@ -443,7 +473,7 @@ func TestRunTimeHandler_Valid_Preview(t *testing.T) {
443473 })
444474
445475 req := createRequest (http .MethodPost , "/preview" , body , http.Header {
446- "command " : []string {"preview" },
476+ "Command " : []string {"preview" },
447477 })
448478
449479 resp := handler .Handle (context .Background (), req )
@@ -501,7 +531,7 @@ func TestRunTimeHandler_Invalid_Preview_Incorrect_Args(t *testing.T) {
501531 })
502532
503533 req := createRequest (http .MethodPost , "/preview" , body , http.Header {
504- "command " : []string {"preview" },
534+ "Command " : []string {"preview" },
505535 })
506536
507537 resp := handler .Handle (context .Background (), req )
0 commit comments