github.com/go-playground/pkg/v5@v5.29.1/net/url/helpers_test.go (about)

     1  package urlext
     2  
     3  import (
     4  	"testing"
     5  
     6  	. "github.com/go-playground/assert/v2"
     7  )
     8  
     9  func TestEncodeToURLValues(t *testing.T) {
    10  	type Test struct {
    11  		Domain string `form:"domain"`
    12  		Next   string `form:"next"`
    13  	}
    14  
    15  	s := Test{Domain: "company.org", Next: "NIDEJ89#(@#NWJK"}
    16  	values, err := EncodeToURLValues(s)
    17  	Equal(t, err, nil)
    18  	Equal(t, len(values), 2)
    19  	Equal(t, values.Encode(), "domain=company.org&next=NIDEJ89%23%28%40%23NWJK")
    20  }