MCPcopy
hub / github.com/uber-go/zap / TestConfigWithMissingAttributes

Function TestConfigWithMissingAttributes

config_test.go:110–144  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

108}
109
110func TestConfigWithMissingAttributes(t *testing.T) {
111 tests := []struct {
112 desc string
113 cfg Config
114 expectErr string
115 }{
116 {
117 desc: "missing level",
118 cfg: Config{
119 Encoding: "json",
120 },
121 expectErr: "missing Level",
122 },
123 {
124 desc: "missing encoder time in encoder config",
125 cfg: Config{
126 Level: NewAtomicLevelAt(zapcore.InfoLevel),
127 Encoding: "json",
128 EncoderConfig: zapcore.EncoderConfig{
129 MessageKey: "msg",
130 TimeKey: "ts",
131 },
132 },
133 expectErr: "missing EncodeTime in EncoderConfig",
134 },
135 }
136
137 for _, tt := range tests {
138 t.Run(tt.desc, func(t *testing.T) {
139 cfg := tt.cfg
140 _, err := cfg.Build()
141 assert.EqualError(t, err, tt.expectErr)
142 })
143 }
144}
145
146func makeSamplerCountingHook() (h func(zapcore.Entry, zapcore.SamplingDecision),
147 dropped, sampled *atomic.Int64,

Callers

nothing calls this directly

Calls 2

NewAtomicLevelAtFunction · 0.85
BuildMethod · 0.80

Tested by

no test coverage detected