-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdump_test.go
More file actions
50 lines (41 loc) · 1.03 KB
/
dump_test.go
File metadata and controls
50 lines (41 loc) · 1.03 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
package proteus_test
import (
"bytes"
"testing"
"github.com/simplesurance/proteus"
"github.com/simplesurance/proteus/internal/assert"
"github.com/simplesurance/proteus/plog"
"github.com/simplesurance/proteus/sources/cfgtest"
"github.com/simplesurance/proteus/types"
)
func TestDump(t *testing.T) {
params := struct {
Server string
Port uint16 `param:",optional"`
Token string `param:",optional,secret"`
Key string `param:",secret"`
}{
Port: 8080,
Token: "secret-token",
}
provider := cfgtest.New(types.ParamValues{
"": {
"server": "localhost",
"key": "secret-key",
},
})
parsed, err := proteus.MustParse(¶ms,
proteus.WithLogger(plog.TestLogger(t)),
proteus.WithProviders(provider))
assert.NoErrorNow(t, err)
usageBuffer := bytes.Buffer{}
parsed.Dump(&usageBuffer)
t.Log(usageBuffer.String())
assert.Equal(t, `Parameter values:
- help = "false" (default)
- key = "<redacted>"
- port = "8080" (default)
- server = "localhost"
- token = "<redacted>" (default)
`, usageBuffer.String())
}