...
1 package urlx
2
3 import (
4 "net/url"
5 "testing"
6
7 "github.com/stretchr/testify/assert"
8 )
9
10 func TestCopyWithQuery(t *testing.T) {
11 a, _ := url.Parse("https://google.com/foo?bar=baz")
12 b := CopyWithQuery(a, url.Values{"foo": {"bar"}})
13 assert.NotEqual(t, a.String(), b.String())
14 assert.Equal(t, "bar", b.Query().Get("foo"))
15 }
16
17 func TestCopy(t *testing.T) {
18 a, _ := url.Parse("https://google.com/foo?bar=baz")
19 b := Copy(a)
20 b.Path = "bar"
21 assert.NotEqual(t, a.String(), b.String())
22 }
23
View as plain text