mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-06 23:16:53 +00:00
Requester update (#203)
* Adds upgrade to re-do request on client timeout. * Updated readme with documentation tool. * Add Requester variable for timeout retry Improve tests
This commit is contained in:
committed by
Adrian Gallagher
parent
baffb46300
commit
f6060ff1fc
@@ -2,6 +2,7 @@ package request
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -284,4 +285,40 @@ func TestDoRequest(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal("unexpected values")
|
||||
}
|
||||
|
||||
err = r.SetTimeoutRetryAttempts(1)
|
||||
if err != nil {
|
||||
t.Fatal("test failed - setting timeout retry attempts")
|
||||
}
|
||||
|
||||
err = r.SetTimeoutRetryAttempts(-1)
|
||||
if err == nil {
|
||||
t.Fatal("test failed - setting timeout retry attempts with negative value")
|
||||
}
|
||||
|
||||
r.HTTPClient.Timeout = 1 * time.Second
|
||||
err = r.SendPayload("POST", "https://httpstat.us/200?sleep=20000", nil, nil, nil, false, true)
|
||||
if err == nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
proxy, err := url.Parse("")
|
||||
if err != nil {
|
||||
t.Error("failed to parse proxy address")
|
||||
}
|
||||
|
||||
err = r.SetProxy(proxy)
|
||||
if err == nil {
|
||||
t.Error("failed to set proxy")
|
||||
}
|
||||
|
||||
proxy, err = url.Parse("https://192.0.0.1")
|
||||
if err != nil {
|
||||
t.Error("failed to parse proxy address")
|
||||
}
|
||||
|
||||
err = r.SetProxy(proxy)
|
||||
if err != nil {
|
||||
t.Error("failed to set proxy")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user