-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgenerator_test.go
53 lines (45 loc) · 1.11 KB
/
generator_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
package log
import (
"testing"
asst "github.com/stretchr/testify/assert"
requir "github.com/stretchr/testify/require"
)
func TestLoggerConfig_RenderTo(t *testing.T) {
cfgs := []struct {
name string
c StructLoggerConfig
rendered string
}{
{"default field", StructLoggerConfig{"*YAMLConfig", "c", ""}, `
func (c *YAMLConfig) SetLogger(logger *dlog.Logger) {
c.log = logger
}
func (c *YAMLConfig) GetLogger() *dlog.Logger {
return c.log
}
func (c *YAMLConfig) LoggerIdentity(justCallMe func() dlog.Identity) dlog.Identity {
return justCallMe()
}
`},
{"specified field", StructLoggerConfig{"*YAMLConfig", "c", "logger"}, `
func (c *YAMLConfig) SetLogger(logger *dlog.Logger) {
c.logger = logger
}
func (c *YAMLConfig) GetLogger() *dlog.Logger {
return c.logger
}
func (c *YAMLConfig) LoggerIdentity(justCallMe func() dlog.Identity) dlog.Identity {
return justCallMe()
}
`},
}
for _, cfg := range cfgs {
t.Run(cfg.name, func(t *testing.T) {
assert := asst.New(t)
require := requir.New(t)
b, err := cfg.c.Render()
require.Nil(err)
assert.Equal(cfg.rendered, string(b))
})
}
}