-
Notifications
You must be signed in to change notification settings - Fork 1
/
tunnel_test.go
45 lines (36 loc) · 1.08 KB
/
tunnel_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
package lokal
import (
"testing"
"github.com/go-resty/resty/v2"
"github.com/stretchr/testify/assert"
)
func TestNewDefault(t *testing.T) {
instance, err := NewDefault()
assert.NoError(t, err)
assert.NotNil(t, instance)
assert.Equal(t, "http://127.0.0.1:6174", instance.baseURL)
assert.NotNil(t, instance.rest)
assert.NotEqual(t, resty.New().BaseURL, instance.rest.BaseURL)
}
func TestSetBaseURL(t *testing.T) {
instance, _ := NewDefault()
newURL := "http://localhost:8080"
instance.SetBaseURL(newURL)
assert.Equal(t, newURL, instance.baseURL)
assert.Equal(t, newURL, instance.rest.BaseURL)
}
func TestSetBasicAuth(t *testing.T) {
instance, _ := NewDefault()
username := "user"
password := "pass"
instance.SetBasicAuth(username, password)
assert.Equal(t, username, instance.basicAuth.Username)
assert.Equal(t, password, instance.basicAuth.Password)
}
func TestSetAPIToken(t *testing.T) {
instance, _ := NewDefault()
token := "mytoken"
instance.SetAPIToken(token)
assert.Equal(t, token, instance.token)
assert.Equal(t, token, instance.rest.Header.Get("X-Auth-Token"))
}