Skip to content

Commit

Permalink
Explicitly place table tests in named variable
Browse files Browse the repository at this point in the history
This makes for slightly more readable code.
  • Loading branch information
jquirke committed Sep 10, 2023
1 parent f600804 commit edc75e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 7 additions & 4 deletions logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func TestLoggerInitialFields(t *testing.T) {

func TestLoggerWith(t *testing.T) {

for _, tt := range []struct {
tests := []struct {
name string
initialFields []Field
withMethodExpr func(*Logger, ...Field) *Logger
Expand All @@ -150,7 +150,8 @@ func TestLoggerWith(t *testing.T) {
[]Field{},
(*Logger).WithLazy,
},
} {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
withLogger(t, DebugLevel, opts(Fields(tt.initialFields...)), func(logger *Logger, logs *observer.ObservedLogs) {
// Child loggers should have copy-on-write semantics, so two children
Expand All @@ -174,7 +175,7 @@ func TestLoggerWith(t *testing.T) {
}

func TestLoggerWithCaptures(t *testing.T) {
for _, tt := range []struct {
tests := []struct {
name string
withMethodExpr func(*Logger, ...Field) *Logger
wantJSON [2]string
Expand Down Expand Up @@ -211,7 +212,9 @@ func TestLoggerWithCaptures(t *testing.T) {
}`,
},
},
} {
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
enc := zapcore.NewJSONEncoder(zapcore.EncoderConfig{
MessageKey: "m",
Expand Down
5 changes: 3 additions & 2 deletions zapcore/lazy_with_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func withLazyCore(f func(zapcore.Core, *proxyCore, *observer.ObservedLogs), init
}

func TestLazyCore(t *testing.T) {
for _, tt := range []struct {
tests := []struct {
name string
entries []zapcore.Entry
initialFields []zapcore.Field
Expand Down Expand Up @@ -114,7 +114,8 @@ func TestLazyCore(t *testing.T) {
},
},
},
} {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
withLazyCore(func(lazy zapcore.Core, proxy *proxyCore, logs *observer.ObservedLogs) {
checkCounts := func(withCount int64, msg string) {
Expand Down

0 comments on commit edc75e6

Please sign in to comment.