bot: use timeout for the default http client

pull/558/head
Demian 2 years ago
parent d4c80e6239
commit 2e4664a387

@ -9,6 +9,7 @@ import (
"regexp"
"strconv"
"strings"
"time"
)
// NewBot does try to build a Bot with token `token`, which
@ -20,7 +21,7 @@ func NewBot(pref Settings) (*Bot, error) {
client := pref.Client
if client == nil {
client = http.DefaultClient
client = &http.Client{Timeout: time.Minute}
}
if pref.URL == "" {

@ -54,8 +54,8 @@ func TestNewBot(t *testing.T) {
assert.NotNil(t, b.Me)
assert.Equal(t, DefaultApiURL, b.URL)
assert.Equal(t, http.DefaultClient, b.client)
assert.Equal(t, 100, cap(b.Updates))
assert.NotZero(t, b.client.Timeout)
pref = defaultSettings()
client := &http.Client{Timeout: time.Minute}

Loading…
Cancel
Save