-
Notifications
You must be signed in to change notification settings - Fork 1
/
client_test.go
59 lines (50 loc) · 1.36 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
56
57
58
59
package eclair
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewClient(t *testing.T) {
client := NewClient()
assert.NotNil(t, client)
assert.NotNil(t, client.settings)
assert.NotNil(t, client.HTTPClient)
}
func TestNewClientFromSettings(t *testing.T) {
settings := NewDefaultSettings()
client := NewClientFromSettings(settings)
assert.NotNil(t, client)
assert.Equal(t, settings, client.settings)
assert.NotNil(t, client.HTTPClient)
}
func TestClient_settings(t *testing.T) {
client := NewClient()
assert.NotNil(t, client._settings())
assert.Equal(t, client.settings, client._settings())
}
func TestClient_WithBaseURL(t *testing.T) {
client := NewClient()
baseURL := "http://localhost:8080"
client.WithBaseURL(baseURL)
assert.Equal(t, baseURL, client.BaseURL)
}
func TestClient_WithCredentials(t *testing.T) {
client := NewClient()
creds := &Credentials{
User: "user",
Password: "password",
}
client.WithCredentials(creds)
assert.Equal(t, creds, client.settings.Credentials)
}
func TestClient_WithUser(t *testing.T) {
client := NewClient()
user := "user"
client.WithUser(user)
assert.Equal(t, user, client.settings.Credentials.User)
}
func TestClient_WithPassword(t *testing.T) {
client := NewClient()
password := "password"
client.WithPassword(password)
assert.Equal(t, password, client.settings.Credentials.Password)
}