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

Function TestPathValuesBinder

binder_test.go:65–88  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

63}
64
65func TestPathValuesBinder(t *testing.T) {
66 c := createTestContext("/api/user/999", nil, map[string]string{
67 "id": "1",
68 "nr": "2",
69 "slice": "3",
70 })
71 b := PathValuesBinder(c)
72
73 id := int64(99)
74 nr := int64(88)
75 var slice = make([]int64, 0)
76 var notExisting = make([]int64, 0)
77 err := b.Int64("id", &id).
78 Int64("nr", &nr).
79 Int64s("slice", &slice).
80 Int64s("not_existing", &notExisting).
81 BindError()
82
83 assert.NoError(t, err)
84 assert.Equal(t, int64(1), id)
85 assert.Equal(t, int64(2), nr)
86 assert.Equal(t, []int64{3}, slice) // binding params to slice does not make sense but it should not panic either
87 assert.Equal(t, []int64{}, notExisting) // binding params to slice does not make sense but it should not panic either
88}
89
90func TestQueryParamsBinder_FailFast(t *testing.T) {
91 var testCases = []struct {

Callers

nothing calls this directly

Calls 5

createTestContextFunction · 0.85
PathValuesBinderFunction · 0.85
BindErrorMethod · 0.80
Int64sMethod · 0.80
Int64Method · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…