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

Function TestBindUnmarshalText

bind_test.go:336–356  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

334}
335
336func TestBindUnmarshalText(t *testing.T) {
337 e := New()
338 req := httptest.NewRequest(http.MethodGet, "/?ts=2016-12-06T19:09:05Z&sa=one,two,three&ta=2016-12-06T19:09:05Z&ta=2016-12-06T19:09:05Z&ST=baz", nil)
339 rec := httptest.NewRecorder()
340 c := e.NewContext(req, rec)
341 result := struct {
342 T time.Time `query:"ts"`
343 ST Struct
344 TA []time.Time `query:"ta"`
345 SA StringArray `query:"sa"`
346 }{}
347 err := c.Bind(&result)
348 ts := time.Date(2016, 12, 6, 19, 9, 5, 0, time.UTC)
349 if assert.NoError(t, err) {
350 // assert.Equal(t, Timestamp(reflect.TypeOf(&Timestamp{}), time.Date(2016, 12, 6, 19, 9, 5, 0, time.UTC)), result.T)
351 assert.Equal(t, ts, result.T)
352 assert.Equal(t, StringArray([]string{"one", "two", "three"}), result.SA)
353 assert.Equal(t, []time.Time{ts, ts}, result.TA)
354 assert.Equal(t, Struct{""}, result.ST) // field in child struct does not have tag
355 }
356}
357
358func TestBindUnmarshalParamPtr(t *testing.T) {
359 e := New()

Callers

nothing calls this directly

Calls 4

BindMethod · 0.95
NewFunction · 0.85
StringArrayTypeAlias · 0.85
NewContextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…