-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequestURLValue_test.go
61 lines (52 loc) · 1.31 KB
/
requestURLValue_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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* @Author: nijineko
* @Date: 2024-08-31 04:16:57
* @LastEditTime: 2024-08-31 04:18:18
* @LastEditors: nijineko
* @Description: 请求URL参数测试
* @FilePath: \yuzuhttp\requestURLValue_test.go
*/
package yuzuhttp
import (
"testing"
)
func TestAddURLValue(t *testing.T) {
var Data map[string]any
if err := Get("http://"+testServer+"/").AddURLValue("client", "yuzuhttp").Do().BodyJSON(&Data); err != nil {
t.Error(err)
return
}
if Data["url"] != "/?client=yuzuhttp" {
t.Error("URL error")
return
}
Data = make(map[string]any)
if err := Get("http://"+testServer+"/").AddQuery("client", "yuzuhttp").Do().BodyJSON(&Data); err != nil {
t.Error(err)
return
}
if Data["url"] != "/?client=yuzuhttp" {
t.Error("URL error")
return
}
}
func TestSetURLValues(t *testing.T) {
var Data map[string]any
if err := Get("http://" + testServer + "/").SetURLValues(map[string]string{"client": "yuzuhttp"}).Do().BodyJSON(&Data); err != nil {
t.Error(err)
return
}
if Data["url"] != "/?client=yuzuhttp" {
t.Error("URL error")
return
}
Data = make(map[string]any)
if err := Get("http://" + testServer + "/").SetQuerys(map[string]string{"client": "yuzuhttp"}).Do().BodyJSON(&Data); err != nil {
t.Error(err)
return
}
if Data["url"] != "/?client=yuzuhttp" {
t.Error("URL error")
return
}
}