test: fix type assertion in autocomplete test
- Change type assertion from []map[string]interface{} to []interface{}
- JSON unmarshal into interface{} creates []interface{}, not typed slices
- Fixes panic: interface conversion error in test
The response["results"] field needs to be asserted as []interface{}
when the parent is unmarshaled into map[string]interface{}.
This matches Go's JSON unmarshaling behavior for interface{} types.
This commit is contained in:
@@ -114,7 +114,7 @@ func TestTagsFilter(t *testing.T) {
|
||||
err := json.Unmarshal(rec.Body.Bytes(), &response)
|
||||
require.NoError(t, err)
|
||||
|
||||
results := response["results"].([]map[string]interface{})
|
||||
results := response["results"].([]interface{})
|
||||
assert.Greater(t, len(results), 0, "Should return 'Science Fiction' in autocomplete results")
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user