Skip to content

Commit

Permalink
fix: zap-time-encoding test should allow negative tz offset
Browse files Browse the repository at this point in the history
The regex used to test whether the times were being properly encoded as
ISO8601 only permitted either positive tz offsets or Z. This fix adjusts
the regex to also allow negative offsets.

Signed-off-by: John Strunk <jstrunk@redhat.com>
  • Loading branch information
JohnStrunk committed Apr 5, 2022
1 parent 05aa087 commit 3847eeb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/log/zap/zap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ var _ = Describe("Zap log level flag options setup", func() {

It("Should propagate time encoder to logger", func() {
// zaps ISO8601TimeEncoder uses 2006-01-02T15:04:05.000Z0700 as pattern for iso8601 encoding
iso8601Pattern := `^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}(\+[0-9]{4}|Z)`
iso8601Pattern := `^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}([-+][0-9]{4}|Z)`

args := []string{"--zap-time-encoding=iso8601"}
fromFlags.BindFlags(&fs)
Expand Down

0 comments on commit 3847eeb

Please sign in to comment.