Skip to content

Commit

Permalink
more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
tmzane committed Oct 24, 2023
1 parent c536a29 commit b4e9ed4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions testdata/src/key_naming_case/key_naming_case.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ func tests() {
slog.Info("msg", slog.Attr{Key: snakeKey})
slog.Info("msg", slog.Attr{Key: "foo_bar", Value: slog.IntValue(1)})
slog.Info("msg", slog.Attr{Key: snakeKey, Value: slog.IntValue(1)})
slog.Info("msg", slog.Attr{Value: slog.IntValue(1), Key: "foo_bar"})
slog.Info("msg", slog.Attr{Value: slog.IntValue(1), Key: snakeKey})

slog.Info("msg", "foo-bar", 1) // want `keys should be written in snake_case`
slog.Info("msg", kebabKey, 1) // want `keys should be written in snake_case`
Expand All @@ -31,4 +33,6 @@ func tests() {
slog.Info("msg", slog.Attr{Key: kebabKey}) // want `keys should be written in snake_case`
slog.Info("msg", slog.Attr{Key: "foo-bar", Value: slog.IntValue(1)}) // want `keys should be written in snake_case`
slog.Info("msg", slog.Attr{Key: kebabKey, Value: slog.IntValue(1)}) // want `keys should be written in snake_case`
slog.Info("msg", slog.Attr{Value: slog.IntValue(1), Key: "foo-bar"}) // want `keys should be written in snake_case`
slog.Info("msg", slog.Attr{Value: slog.IntValue(1), Key: kebabKey}) // want `keys should be written in snake_case`
}
2 changes: 2 additions & 0 deletions testdata/src/no_raw_keys/no_raw_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ func tests() {
slog.Info("msg", slog.Attr{Key: foo})
slog.Info("msg", slog.Attr{Value: slog.IntValue(1)})
slog.Info("msg", slog.Attr{Key: foo, Value: slog.IntValue(1)})
slog.Info("msg", slog.Attr{Value: slog.IntValue(1), Key: foo})

slog.Info("msg", "foo", 1) // want `raw keys should not be used`
slog.Info("msg", slog.Int("foo", 1)) // want `raw keys should not be used`
slog.Info("msg", slog.Attr{"foo", slog.IntValue(1)}) // want `raw keys should not be used`
slog.Info("msg", slog.Attr{Key: "foo"}) // want `raw keys should not be used`
slog.Info("msg", slog.Attr{Key: "foo", Value: slog.IntValue(1)}) // want `raw keys should not be used`
slog.Info("msg", slog.Attr{Value: slog.IntValue(1), Key: "foo"}) // want `raw keys should not be used`
}

0 comments on commit b4e9ed4

Please sign in to comment.