forked from levigross/grequests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
request_test.go
39 lines (29 loc) · 1015 Bytes
/
request_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package requests
import "testing"
func TestAddQueryStringParams(t *testing.T) {
userURL, err := buildURLParams("https://www.google.com/", map[string]string{"1": "2", "3": "4"})
if err != nil {
t.Error("URL Parse Error: ", err)
}
if userURL != "https://www.google.com/?1=2&3=4" {
t.Error("URL params not properly built", userURL)
}
}
func TestSortAddQueryStringParams(t *testing.T) {
userURL, err := buildURLParams("https://www.google.com/", map[string]string{"3": "4", "1": "2"})
if err != nil {
t.Error("URL Parse Error: ", err)
}
if userURL != "https://www.google.com/?1=2&3=4" {
t.Error("URL params not properly built and sorted", userURL)
}
}
func TestAddQueryStringParamsExistingParam(t *testing.T) {
userURL, err := buildURLParams("https://www.google.com/?5=6", map[string]string{"3": "4", "1": "2"})
if err != nil {
t.Error("URL Parse Error: ", err)
}
if userURL != "https://www.google.com/?1=2&3=4&5=6" {
t.Error("URL params not properly built and sorted", userURL)
}
}