gin/binding/query_test.go
illiafox 8790d08909
fix(uri): query binding bug (#3236)
* fix query mapping

* query binding test
2024-03-21 22:28:42 +08:00

24 lines
389 B
Go

package binding
import (
"net/http"
"net/url"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestQueryBinding(t *testing.T) {
var s struct {
Foo string `query:"foo"`
}
request := &http.Request{URL: &url.URL{RawQuery: "foo=BAR"}}
err := queryBinding{}.Bind(request, &s)
require.NoError(t, err)
assert.Equal(t, "BAR", s.Foo)
}