Skip to content

Commit 65527eb

Browse files
EconoBenclaude
andcommitted
test: add test for invalid view_type in fast search endpoint
Addresses roborev testing gap finding by adding a test that verifies the /api/v1/search/fast endpoint returns 400 Bad Request with error code 'invalid_view_type' when an invalid view_type is provided. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 56a2d4f commit 65527eb

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

internal/api/handlers_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,29 @@ func TestHandleFastSearchMissingQuery(t *testing.T) {
10121012
}
10131013
}
10141014

1015+
func TestHandleFastSearchInvalidViewType(t *testing.T) {
1016+
engine := &querytest.MockEngine{}
1017+
srv := newTestServerWithEngine(t, engine)
1018+
1019+
req := httptest.NewRequest("GET", "/api/v1/search/fast?q=test&view_type=invalid", nil)
1020+
w := httptest.NewRecorder()
1021+
1022+
srv.Router().ServeHTTP(w, req)
1023+
1024+
if w.Code != http.StatusBadRequest {
1025+
t.Errorf("status = %d, want %d", w.Code, http.StatusBadRequest)
1026+
}
1027+
1028+
var errResp map[string]string
1029+
if err := json.NewDecoder(w.Body).Decode(&errResp); err != nil {
1030+
t.Fatalf("failed to decode error response: %v", err)
1031+
}
1032+
1033+
if errResp["error"] != "invalid_view_type" {
1034+
t.Errorf("error = %q, want 'invalid_view_type'", errResp["error"])
1035+
}
1036+
}
1037+
10151038
func TestHandleDeepSearch(t *testing.T) {
10161039
engine := &querytest.MockEngine{
10171040
SearchResults: []query.MessageSummary{

0 commit comments

Comments
 (0)