-
-
Notifications
You must be signed in to change notification settings - Fork 216
Expand file tree
/
Copy pathcmd_test.go
More file actions
51 lines (45 loc) · 1.05 KB
/
cmd_test.go
File metadata and controls
51 lines (45 loc) · 1.05 KB
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
package caddydockerproxy
import (
"testing"
"github.com/lucaslorentz/caddy-docker-proxy/v2/config"
"github.com/stretchr/testify/assert"
)
func TestNormalizeAdminListen(t *testing.T) {
testCases := []struct {
name string
input string
expected string
}{
{
name: "empty",
input: "",
expected: "",
},
{
name: "trim and add tcp prefix",
input: " 0.0.0.0:2019 ",
expected: "tcp/0.0.0.0:2019",
},
{
name: "keep prefixed listen value",
input: "tcp/0.0.0.0:2019",
expected: "tcp/0.0.0.0:2019",
},
{
name: "keep unix listen value",
input: "unix//run/caddy-admin.sock",
expected: "unix//run/caddy-admin.sock",
},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
assert.Equal(t, testCase.expected, normalizeAdminListen(testCase.input))
})
}
}
func TestGetAdminListenPrefersConfiguredListen(t *testing.T) {
options := &config.Options{
AdminListen: "tcp/0.0.0.0:2019",
}
assert.Equal(t, "tcp/0.0.0.0:2019", getAdminListen(options))
}