Skip to content

Commit

Permalink
integration-tests: sanity check the parsed times a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
jrockway committed May 2, 2021
1 parent 21e541c commit 27dcc93
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions integration-tests/loggers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ type ignoreTimeFormatter struct {
func (f *ignoreTimeFormatter) FormatTime(s *parse.State, t time.Time, w *bytes.Buffer) {
f.i++
w.WriteString(strconv.Itoa(f.i))
// Check that the time is in some plausible range. These could be very close to time.Now(),
// but for Bunyan we hard-coded some times that get farther into the past every day.
if t.After(time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)) && t.Before(time.Date(2030, 1, 1, 0, 0, 0, 0, time.UTC)) {
w.WriteString(" ok")
} else {
w.WriteString(" fail")
}
}

func TestLoggers(t *testing.T) {
Expand Down Expand Up @@ -204,9 +211,9 @@ func TestLoggers(t *testing.T) {
Formatter: f,
}
want := `
INFO 1 line 1
INFO 2 line 2 string:value int:42 object:{"foo":"bar"}
INFO 3 line 3 error:whoa
INFO 1 ok line 1
INFO 2 ok line 2 string:value int:42 object:{"foo":"bar"}
INFO 3 ok line 3 error:whoa
`[1:]
for _, test := range testData {
subTests := map[string]*parse.InputSchema{
Expand Down

0 comments on commit 27dcc93

Please sign in to comment.