TestBindCachedMetaPreservesFieldNameError ensures the per-type bind metadata cache preserves the field-name prefix in conversion errors on BOTH the cold (first) and warm (cached) bind of a type. DTO is declared locally so its reflect.Type is independent of suite ordering, making the second bind a de
(t *testing.T)
| 16 | // DTO is declared locally so its reflect.Type is independent of suite ordering, making the second |
| 17 | // bind a deterministic cache hit (the bindMetaFor Load branch). |
| 18 | func TestBindCachedMetaPreservesFieldNameError(t *testing.T) { |
| 19 | type DTO struct { |
| 20 | Number int `query:"number"` |
| 21 | } |
| 22 | bind := func() error { |
| 23 | e := New() |
| 24 | req := httptest.NewRequest(http.MethodGet, "/?number=10a", nil) |
| 25 | var dto DTO |
| 26 | return e.NewContext(req, httptest.NewRecorder()).Bind(&dto) |
| 27 | } |
| 28 | |
| 29 | assert.ErrorContains(t, bind(), "number", "cold cache: error must carry field name") |
| 30 | assert.ErrorContains(t, bind(), "number", "warm cache: error must still carry field name") |
| 31 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…