MCPcopy Index your code
hub / github.com/labstack/echo / TestContext_QueryParams

Function TestContext_QueryParams

context_test.go:819–856  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

817}
818
819func TestContext_QueryParams(t *testing.T) {
820 var testCases = []struct {
821 expect url.Values
822 name string
823 givenURL string
824 }{
825 {
826 name: "multiple values in url",
827 givenURL: "/?test=1&test=2&email=jon%40labstack.com",
828 expect: url.Values{
829 "test": []string{"1", "2"},
830 "email": []string{"jon@labstack.com"},
831 },
832 },
833 {
834 name: "single value in url",
835 givenURL: "/?nope=1",
836 expect: url.Values{
837 "nope": []string{"1"},
838 },
839 },
840 {
841 name: "no query params in url",
842 givenURL: "/?",
843 expect: url.Values{},
844 },
845 }
846
847 for _, tc := range testCases {
848 t.Run(tc.name, func(t *testing.T) {
849 req := httptest.NewRequest(http.MethodGet, tc.givenURL, nil)
850 e := New()
851 c := e.NewContext(req, nil)
852
853 assert.Equal(t, tc.expect, c.QueryParams())
854 })
855 }
856}
857
858func TestContext_QueryParam(t *testing.T) {
859 var testCases = []struct {

Callers

nothing calls this directly

Calls 3

QueryParamsMethod · 0.95
NewFunction · 0.85
NewContextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…