This commit is contained in:
2022-10-31 17:22:49 +08:00
parent 63c8b46474
commit 9f29f019ad
11 changed files with 96 additions and 99 deletions

View File

@@ -1,6 +1,6 @@
/**
* @Author: fuxiao
* @Email: 576101059@qq.com
* @Author: Echo
* @Email: 1711788888@qq.com
* @Date: 2021/8/16 2:54 下午
* @Desc: TODO
*/
@@ -10,8 +10,8 @@ package http_test
import (
"errors"
"testing"
"github.com/dobyte/http"
"git.echol.cn/loser/http"
)
const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlc2MiOjE2MjgwNDAzMjYxNTQ2MzIwMDAsImV4cCI6MTYyODIyMDMyNiwiaWF0IjoxNjI4MDQwMzI2LCJpZCI6MX0.KM19c6URIih-5SyycYIjNAdSiPKxMQEz3DoROm0N3nw"
@@ -23,13 +23,13 @@ func TestClient_Request(t *testing.T) {
}).Use(func(r *http.Request) (*http.Response, error) {
return nil, errors.New("Invalid params.")
})
resp, err := client.Request(http.MethodGet, "/common/regions")
if err != nil {
t.Error(err)
return
}
t.Log(resp.Response.Status)
}
@@ -42,7 +42,7 @@ func TestClient_Post(t *testing.T) {
r.Request.Header.Set("Client-Type", "2")
return r.Next()
})
type updateRegionArg struct {
Id int `json:"id"`
Pid int `json:"pid"`
@@ -50,7 +50,7 @@ func TestClient_Post(t *testing.T) {
Name string `json:"name"`
Sort int `json:"sort"`
}
data := updateRegionArg{
Id: 1,
Pid: 0,
@@ -58,7 +58,7 @@ func TestClient_Post(t *testing.T) {
Name: "北京市",
Sort: 0,
}
if resp, err := client.Put("/backend/region/update-region", data); err != nil {
t.Error(err)
return
@@ -74,7 +74,7 @@ func TestClient_Post(t *testing.T) {
func TestClient_Download(t *testing.T) {
url := "https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png"
if path, err := http.NewClient().Download(url, "./"); err != nil {
t.Error(err)
return