-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclient_test.go
More file actions
38 lines (30 loc) · 740 Bytes
/
client_test.go
File metadata and controls
38 lines (30 loc) · 740 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
package dictionaryapi
import (
"testing"
"github.com/go-resty/resty/v2"
"github.com/stretchr/testify/assert"
)
var (
client *Client
)
func init() {
client = NewClient()
}
func TestClient_NewClient(t *testing.T) {
t.Run("default", func(t *testing.T) {
client := NewClient()
assert.NotNil(t, client)
})
t.Run("with custom httpClient", func(t *testing.T) {
httpClient := resty.New()
client := NewClient(WithHTTPClient(httpClient))
assert.NotNil(t, client)
assert.Exactly(t, httpClient, client.httpClient)
})
t.Run("with custom WordManager", func(t *testing.T) {
wm := &wordManager{Client: client}
client := NewClient(WithWordsManager(wm))
assert.NotNil(t, client)
assert.Exactly(t, wm, client.Word)
})
}