Skip to content

Commit

Permalink
Fix unittests for new year (influxdata#5213)
Browse files Browse the repository at this point in the history
  • Loading branch information
svenwiltink authored and Max Eshleman committed Feb 13, 2019
1 parent 3c42d4e commit cd51932
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions plugins/parsers/grok/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@ func TestNewlineInPatterns(t *testing.T) {
}

func TestSyslogTimestamp(t *testing.T) {
currentYear := time.Now().Year()
tests := []struct {
name string
line string
Expand All @@ -915,17 +916,17 @@ func TestSyslogTimestamp(t *testing.T) {
{
name: "two digit day of month",
line: "Sep 25 09:01:55 value=42",
expected: time.Date(2018, time.September, 25, 9, 1, 55, 0, time.UTC),
expected: time.Date(currentYear, time.September, 25, 9, 1, 55, 0, time.UTC),
},
{
name: "one digit day of month single space",
line: "Sep 2 09:01:55 value=42",
expected: time.Date(2018, time.September, 2, 9, 1, 55, 0, time.UTC),
expected: time.Date(currentYear, time.September, 2, 9, 1, 55, 0, time.UTC),
},
{
name: "one digit day of month double space",
line: "Sep 2 09:01:55 value=42",
expected: time.Date(2018, time.September, 2, 9, 1, 55, 0, time.UTC),
expected: time.Date(currentYear, time.September, 2, 9, 1, 55, 0, time.UTC),
},
}
for _, tt := range tests {
Expand Down Expand Up @@ -1023,5 +1024,5 @@ func TestEmptyYearInTimestamp(t *testing.T) {
m, err := p.ParseLine("Nov 6 13:57:03 generic iTunes[6504]: objc[6504]: Object descriptor was null.")
require.NoError(t, err)
require.NotNil(t, m)
require.Equal(t, 2018, m.Time().Year())
require.Equal(t, time.Now().Year(), m.Time().Year())
}

0 comments on commit cd51932

Please sign in to comment.