-
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathclient_test.go
More file actions
41 lines (33 loc) · 637 Bytes
/
client_test.go
File metadata and controls
41 lines (33 loc) · 637 Bytes
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
package rek
import (
"context"
"net/http"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestClientBuilder(t *testing.T) {
var (
timeout = 13 * time.Second
)
is := assert.New(t)
opts := &options{}
// No options
cl := buildClient(opts)
is.Equal(cl, &http.Client{})
// Custom client
client := &http.Client{
Timeout: timeout,
}
opts.client = client
cl = buildClient(opts)
is.Equal(cl.Timeout, timeout)
// OAuth
opts = &options{}
opts.oauth2Cfg = &oauth2Config{
config: oauthCfg,
token: oauthTok,
}
cl = buildClient(opts)
is.Equal(cl, oauthCfg.Client(context.Background(), oauthTok))
}