-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_test.go
44 lines (41 loc) · 1.08 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
package main
import (
"testing"
"github.com/zpatrick/go-config"
"github.com/qnib/doxy/proxy"
"github.com/stretchr/testify/assert"
)
func TestEvalOptions(t *testing.T) {
myCfg := map[string]string{
"proxy-socket": "proxy.sock",
"docker-socket": "docker.sock",
"debug": "true",
}
cfg := config.NewConfig([]config.Provider{config.NewStatic(myCfg)})
got := EvalOptions(cfg)
p := proxy.NewProxy(got...)
exp := map[string]interface{}{
"docker-socket": "docker.sock",
"proxy-socket": "proxy.sock",
"debug": true,
"patterns": []string{},
}
assert.Equal(t, exp, p.GetOptions())
}
func TestEvalPatternOpts(t *testing.T) {
cfg := config.NewConfig([]config.Provider{config.NewStatic(map[string]string{
"docker-socket": "docker.sock",
"proxy-socket": "proxy.sock",
"pattern-file": "some.file",
})})
got := EvalPatternOpts(cfg)
p := proxy.NewProxy(got)
exp := map[string]interface{}{
"docker-socket": "/var/run/docker.sock",
"proxy-socket": "/tmp/doxy.sock",
"debug": false,
"patterns": proxy.DEFAULT_PATTERNS,
}
opts := p.GetOptions()
assert.Equal(t, exp, opts)
}