test: fix autocomplete test to match API response structure

- Update test to unmarshal response object before extracting results array
- API returns {"results": [...], "total": N}, not a bare array
- Fixes "cannot unmarshal object into Go value of type []map" error
- Test now correctly handles the structured autocomplete response

The handleFieldValuesSearch endpoint returns a structured response
with metadata (results array + total count), not a bare array.
This aligns the test with the actual API response format.
This commit is contained in:
2026-03-25 20:59:26 -04:00
parent 0f70f74f12
commit 6a8d2e0e3b
+4 -2
View File
@@ -110,9 +110,11 @@ func TestTagsFilter(t *testing.T) {
assert.Equal(t, http.StatusOK, rec.Code, "Should return autocomplete results")
var results []map[string]interface{}
err := json.Unmarshal(rec.Body.Bytes(), &results)
var response map[string]interface{}
err := json.Unmarshal(rec.Body.Bytes(), &response)
require.NoError(t, err)
results := response["results"].([]map[string]interface{})
assert.Greater(t, len(results), 0, "Should return 'Science Fiction' in autocomplete results")
})