MCPcopy
hub / github.com/gofiber/fiber / Test_Bind_URI

Function Test_Bind_URI

bind_test.go:1781–1802  ·  view source on GitHub ↗

go test -run Test_Bind_URI

(t *testing.T)

Source from the content-addressed store, hash-verified

1779
1780// go test -run Test_Bind_URI
1781func Test_Bind_URI(t *testing.T) {
1782 t.Parallel()
1783
1784 app := New()
1785 app.Get("/test1/userId/role/:roleId", func(c Ctx) error {
1786 type Demo struct {
1787 UserID uint `uri:"userId"`
1788 RoleID uint `uri:"roleId"`
1789 }
1790 d := new(Demo)
1791 if err := c.Bind().URI(d); err != nil {
1792 t.Fatal(err)
1793 }
1794 require.Equal(t, uint(111), d.UserID)
1795 require.Equal(t, uint(222), d.RoleID)
1796 return nil
1797 })
1798 _, err := app.Test(httptest.NewRequest(MethodGet, "/test1/111/role/222", http.NoBody))
1799 require.NoError(t, err)
1800 _, err = app.Test(httptest.NewRequest(MethodGet, "/test2/111/role/222", http.NoBody))
1801 require.NoError(t, err)
1802}
1803
1804// go test -run Test_Bind_URI_Map
1805func Test_Bind_URI_Map(t *testing.T) {

Callers

nothing calls this directly

Calls 6

URIMethod · 0.80
TestMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
BindMethod · 0.65
FatalMethod · 0.65

Tested by

no test coverage detected