Skip to content

Commit 43f712f

Browse files
committed
test: document serial context logger tests
1 parent 0e3b43c commit 43f712f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

log/default_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ func Test_CtxLogger(t *testing.T) {
120120
"[Panic] work panic\n", string(w.b))
121121
}
122122

123+
// Test_WithContextTemplate runs serially because initDefaultLogger,
124+
// SetContextTemplate, MustSetContextTemplate, and SetOutput mutate package
125+
// globals shared with other log tests.
123126
func Test_WithContextTemplate(t *testing.T) {
124127
initDefaultLogger()
125128

@@ -152,6 +155,8 @@ func Test_WithContextTemplate(t *testing.T) {
152155
require.Equal(t, "[Info] [req-42] start\n", string(w.b))
153156
}
154157

158+
// Test_WithContextTemplateFailureOmitsPartialContext runs serially because it
159+
// mutates the same global logger state as Test_WithContextTemplate.
155160
func Test_WithContextTemplateFailureOmitsPartialContext(t *testing.T) {
156161
initDefaultLogger()
157162

@@ -161,7 +166,9 @@ func Test_WithContextTemplateFailureOmitsPartialContext(t *testing.T) {
161166
CustomTags: map[string]ContextTagFunc{
162167
"broken": func(output Buffer, _ any, _ *ContextData, _ string) (int, error) {
163168
_, err := output.WriteString("partial")
164-
require.NoError(t, err)
169+
if err != nil {
170+
return 0, err
171+
}
165172
return 0, templateErr
166173
},
167174
},

0 commit comments

Comments
 (0)