-
Notifications
You must be signed in to change notification settings - Fork 50
/
options_test.go
48 lines (39 loc) · 1.35 KB
/
options_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
package proxmox
import (
"net/http"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestWithClient(t *testing.T) {
httpClient := http.Client{Timeout: time.Second * 10}
client := NewClient("", WithClient(&httpClient))
assert.Equal(t, client.httpClient, &http.Client{Timeout: time.Second * 10})
}
func TestWithLogins(t *testing.T) {
client := NewClient("", WithLogins("root@pam", "1234"))
assert.Equal(t, client.credentials, &Credentials{Username: "root@pam", Password: "1234"})
}
func TestWithCredentials(t *testing.T) {
client := NewClient("", WithCredentials(&Credentials{
Username: "root@pam",
Password: "1234",
}))
assert.Equal(t, client.credentials, &Credentials{Username: "root@pam", Password: "1234"})
}
func TestWithAPIToken(t *testing.T) {
client := NewClient("", WithAPIToken("root@pam!test", "1234"))
assert.Equal(t, client.token, "root@pam!test=1234")
}
func TestWithSession(t *testing.T) {
client := NewClient("", WithSession("ticket", "csrf"))
assert.Equal(t, client.session, &Session{Ticket: "ticket", CSRFPreventionToken: "csrf"})
}
func TestWithUserAgent(t *testing.T) {
client := NewClient("", WithUserAgent("test-ua"))
assert.Equal(t, client.userAgent, "test-ua")
}
func TestWithLogger(t *testing.T) {
client := NewClient("", WithLogger(&LeveledLogger{Level: 1}))
assert.Equal(t, client.log, &LeveledLogger{Level: 1})
}