-
Notifications
You must be signed in to change notification settings - Fork 20
/
client_test.go
55 lines (43 loc) · 1.11 KB
/
client_test.go
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
49
50
51
52
53
54
55
package vk
import (
"net/http"
"testing"
)
func TestNewClient(t *testing.T) {
client, err := NewClient()
if err != nil {
t.Error(err)
}
testDefaultClient(client, t)
}
func TestNewClientWithOptions(t *testing.T) {
token := "TOKEN"
client, err := NewClientWithOptions(
WithToken(token),
WithHTTPClient(http.DefaultClient),
)
if err != nil {
t.Error(err)
}
testDefaultClient(client, t)
if client.Token != token {
t.Errorf("client.Token == %q, want %q", client.Token, token)
}
if client.HTTPClient != http.DefaultClient {
t.Errorf("client.HTTPClient == %v, want %v (http.DefaultClient)", client.HTTPClient, http.DefaultClient)
}
}
func testDefaultClient(client *Client, t *testing.T) {
if client.Lang != DefaultLang {
t.Errorf("client.Lang == %q, want %q", client.Lang, DefaultLang)
}
if client.Version != DefaultVersion {
t.Errorf("client.Version == %q, want %q", client.Version, DefaultVersion)
}
if client.BaseURL != DefaultBaseURL {
t.Errorf("client.BaseURL == %q, want %q", client.BaseURL, DefaultBaseURL)
}
if client.HTTPClient == nil {
t.Error("client.HTTPClient == nil")
}
}