-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_test.go
60 lines (53 loc) · 1.35 KB
/
main_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
60
package proxy
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestProxy_NewProxyWithPattern(t *testing.T) {
p := NewProxy(
WithProxySocket("new"),
WithDockerSocket("old"),
WithPattern("mypat1"),
)
assert.Equal(t, []string{"mypat1"}, p.patterns)
assert.False(t, p.debug, "Debug should be false by default")
}
func TestProxy_NewProxyWithPatterns(t *testing.T) {
p := NewProxy(
WithProxySocket("new"),
WithDockerSocket("old"),
WithPatterns([]string{"mypat1","mypat2"}),
)
assert.Equal(t, []string{"mypat1","mypat2"}, p.patterns)
assert.False(t, p.debug, "Debug should be false by default")
}
func TestProxy_NewProxyWithDebugEnabled(t *testing.T) {
p := NewProxy(
WithProxySocket("new"),
WithDockerSocket("old"),
WithDebugEnabled(),
)
assert.True(t, p.debug, "Debug should be set")
}
func TestProxy_NewProxyWithDebugValue(t *testing.T) {
p := NewProxy(
WithProxySocket("new"),
WithDockerSocket("old"),
WithDebugValue(true),
)
assert.True(t, p.debug, "Debug should be set")
}
func TestProxy_GetOptions(t *testing.T) {
p := NewProxy(
WithProxySocket("proxy.sock"),
WithDockerSocket("docker.sock"),
WithPattern("mypat1"),
)
exp := map[string]interface{}{
"docker-socket": "docker.sock",
"proxy-socket": "proxy.sock",
"debug": false,
"patterns": []string{"mypat1"},
}
assert.Equal(t, exp, p.GetOptions())
}