Skip to content

Commit

Permalink
bot: use timeout for the default http client
Browse files Browse the repository at this point in the history
  • Loading branch information
demget committed Oct 4, 2022
1 parent d4c80e6 commit 2e4664a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"regexp"
"strconv"
"strings"
"time"
)

// NewBot does try to build a Bot with token `token`, which
Expand All @@ -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 == "" {
Expand Down
2 changes: 1 addition & 1 deletion bot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 2e4664a

Please sign in to comment.