Added client timeout because http.DefaultClient doesn't have timeout

This commit is contained in:
Junpei Tsuji
2018-05-18 12:18:09 +09:00
parent cdb4cd7c54
commit 8e67f122c0
6 changed files with 34 additions and 21 deletions

View File

@@ -7,6 +7,7 @@ import (
"errors"
"io/ioutil"
"net/http"
"time"
)
const (
@@ -78,7 +79,9 @@ func New() *Client {
client := &Client{
ProductionURL: ProductionURL,
SandboxURL: SandboxURL,
httpCli: http.DefaultClient,
httpCli: &http.Client{
Timeout: 10 * time.Second,
},
}
return client
}

View File

@@ -90,7 +90,9 @@ func TestNew(t *testing.T) {
expected := &Client{
ProductionURL: ProductionURL,
SandboxURL: SandboxURL,
httpCli: http.DefaultClient,
httpCli: &http.Client{
Timeout: 10 * time.Second,
},
}
actual := New()