Fix lint and format code in adapter/httplib dir

This commit is contained in:
loyalsoldier 2021-06-05 11:23:12 +08:00
parent fb4c91fd76
commit fc38efb7d4
No known key found for this signature in database
GPG Key ID: 23829BBC1ACF2C90
2 changed files with 11 additions and 12 deletions

View File

@ -4,6 +4,7 @@
- Add: Convenient way to generate mock object [4620](https://github.com/beego/beego/issues/4620)
- Infra: use dependabot to update dependencies. [4623](https://github.com/beego/beego/pull/4623)
- Lint: use golangci-lint. [4619](https://github.com/beego/beego/pull/4619)
- Fix lint and format code in adapter/httplib dir [4648](https://github.com/beego/beego/pull/4648)
- Chore: format code. [4615](https://github.com/beego/beego/pull/4615)
- Test on Go v1.15.x & v1.16.x. [4614](https://github.com/beego/beego/pull/4614)
- Env: non-empty GOBIN & GOPATH. [4613](https://github.com/beego/beego/pull/4613)

View File

@ -26,11 +26,13 @@ import (
"time"
)
const getUrl = "http://httpbin.org/get"
const ipUrl = "http://httpbin.org/ip"
const (
getURL = "http://httpbin.org/get"
ipURL = "http://httpbin.org/ip"
)
func TestResponse(t *testing.T) {
req := Get(getUrl)
req := Get(getURL)
resp, err := req.Response()
if err != nil {
t.Fatal(err)
@ -63,12 +65,10 @@ func TestDoRequest(t *testing.T) {
if elapsedTime < delayedTime {
t.Errorf("Not enough retries. Took %dms. Delay was meant to take %dms", elapsedTime, delayedTime)
}
}
func TestGet(t *testing.T) {
req := Get(getUrl)
req := Get(getURL)
b, err := req.Bytes()
if err != nil {
t.Fatal(err)
@ -210,7 +210,7 @@ func TestWithSetting(t *testing.T) {
setting.ReadWriteTimeout = 5 * time.Second
SetDefaultSetting(setting)
str, err := Get(getUrl).String()
str, err := Get(getURL).String()
if err != nil {
t.Fatal(err)
}
@ -223,8 +223,7 @@ func TestWithSetting(t *testing.T) {
}
func TestToJson(t *testing.T) {
req := Get(ipUrl)
req := Get(ipURL)
resp, err := req.Response()
if err != nil {
t.Fatal(err)
@ -250,12 +249,11 @@ func TestToJson(t *testing.T) {
t.Fatal("response is not valid ip")
}
}
}
func TestToFile(t *testing.T) {
f := "beego_testfile"
req := Get(ipUrl)
req := Get(ipURL)
err := req.ToFile(f)
if err != nil {
t.Fatal(err)
@ -269,7 +267,7 @@ func TestToFile(t *testing.T) {
func TestToFileDir(t *testing.T) {
f := "./files/beego_testfile"
req := Get(ipUrl)
req := Get(ipURL)
err := req.ToFile(f)
if err != nil {
t.Fatal(err)