Skip to content

Commit

Permalink
feat: 添加自定义请求的测试函数
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninohana committed Sep 22, 2024
1 parent bd6fcdd commit 9c4bd92
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lcu_sgp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package lcu
import (
"encoding/json"
"fmt"
"io"
"net/http"
"strings"
"testing"
)
Expand Down Expand Up @@ -81,3 +83,22 @@ func TestNewSgpClient(t *testing.T) {
}
//sgpClient.RefreshToken()
}

func TestLcuClient_CustomRequest(t *testing.T) {
req, _ := http.NewRequest("GET", "/entitlements/v1/token", nil)
resp, err := lcu.Do(req)
if resp == nil {
panic(err)
}
defer func(Body io.ReadCloser) {
_ = Body.Close()
}(resp.Body)
body, _ := io.ReadAll(resp.Body)
if resp.StatusCode < 200 || resp.StatusCode > 299 {
errRes := &errorResponse{}
_ = json.Unmarshal(body, errRes)
t.Error(errRes)
return
}
fmt.Println(string(body))
}

0 comments on commit 9c4bd92

Please sign in to comment.