-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathclient_http_test.go
More file actions
48 lines (33 loc) · 1.16 KB
/
client_http_test.go
File metadata and controls
48 lines (33 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//go:build test
package flagsmith
import (
"testing"
"time"
"github.com/go-resty/resty/v2"
"github.com/stretchr/testify/assert"
)
func (c *Client) ExposeRestyClient() *resty.Client {
return c.client
}
func TestCustomClientRetriesAreSet(t *testing.T) {
retryCount := 5
customResty := resty.New().
SetRetryCount(retryCount).
SetRetryWaitTime(10 * time.Millisecond)
client := NewClient("env-key", WithRestyClient(customResty))
internal := client.ExposeRestyClient()
assert.Equal(t, retryCount, internal.RetryCount)
assert.Equal(t, 10*time.Millisecond, internal.RetryWaitTime)
}
func TestCustomRestyClientTimeoutIsNotOverriddenWithDefaultTimeout(t *testing.T) {
customResty := resty.New().SetTimeout(13 * time.Millisecond)
client := NewClient("env-key", WithRestyClient(customResty))
internal := client.ExposeRestyClient()
assert.Equal(t, 13*time.Millisecond, internal.GetClient().Timeout)
}
func TestCustomRestyClientHasDefaultTimeoutIfNotProvided(t *testing.T) {
customResty := resty.New()
client := NewClient("env-key", WithRestyClient(customResty))
internal := client.ExposeRestyClient()
assert.Equal(t, 10*time.Second, internal.GetClient().Timeout)
}