MCPcopy
hub / github.com/labstack/echo / TestBindCachedMetaPreservesFieldNameError

Function TestBindCachedMetaPreservesFieldNameError

bind_cache_test.go:18–31  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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).
18func 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}

Callers

nothing calls this directly

Calls 3

NewFunction · 0.85
NewContextMethod · 0.80
BindMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…